2013-04-26 47 views
0

我有一些我希望使其具有通用性的例程:代替選定的文件夾,我想在描述文件夾時粘貼到用戶當前用戶(「〜/」)路徑..Automator「Get specified finder items」applescript equivalent

所以我的問題是,如果我在automator中選擇一個帶有「Get Specified Finder Items」的文件夾,那麼會輸出如下所示的一個-non applescript-list :(「path/to/my/folder」),我怎樣才能用applescript複製它。注意圓括號而不是大括號!

首先,我只是想用這個:

on run 
    return {"~/path/to/my/folder/under/current/user"} 
end run 

然後我想補充「獲取文件夾目錄」塊..

誰能告訴我爲什麼會不工作? 在此先感謝!

+0

當然,還有將在多個文件夾中的UNIX類路徑列表..這就是爲什麼我首先需要一個列表。 – ppseprus 2013-04-26 13:23:58

回答

1

嗯,我還不如寄我是爲你反正:-)

set folderTest1 to "test1" 
set folderTest2 to "test2" 


set homePath to POSIX path of (path to home folder as text) as text 
set attachmentsFolder to (homePath & folderTest1 & "/" & folderTest2) as text 

--OR 


set homePath to POSIX path of (path to home folder as text) as text 
set attachmentsFolder to (homePath & "test1/test2") as text 

POSIX PATH打字改變HFS +路徑到一個unix類型路徑

路徑到家文件夾到達用戶主文件夾

路徑文件獲取路徑到用戶文件夾

POSIX文件變成一個HFS +路徑

set homePath to POSIX path of (path to home folder as text) as text 


set theHFSPath to (POSIX file homePath) 
tell application "Finder" 
    --The finder looks for the folders in the alais path of theHFSPath 
    set theFolders to folders of (theHFSPath as alias) as alias list 

    --> returns is a list of folders in the form of alais paths 

end tell 
+0

我最終用下面的語法解決了它: 'return {alias((作爲文本的主文件夾的路徑)&「Library:Caches:Adobe Camera Raw」)}' Ans since this was in「Run AppleScript「塊,我只是附加」獲取文件夾內容「和」移動Finder物品到垃圾「塊。這種方式是普遍的,我可以將它發送給同事。 – ppseprus 2013-04-28 15:06:07

0

我用下面的代碼解決了這個問題:

on run 
return { POSIX path of ((path to home folder as text)) & "/path to my folder" as text, .. } 
end run 
+1

它可以縮寫爲'{(系統屬性「HOME」)&「/我的文件夾路徑}}。腳本有一個隱式運行處理程序,它們返回最後一個值。 '系統屬性「HOME」'與$ HOME相同。 – user495470 2013-04-26 19:45:54

+0

我最終用下面的語法解決了它:''作爲文本返回{別名((作爲文本的主文件夾的路徑)&「Library:Caches:Adobe Camera Raw」)}'因爲這是在「運行AppleScript」塊我的automator應用程序,我只是附加「獲取文件夾內容」和「移動Finder項目toTrash」塊。這種方式是普遍的,我可以將它發送給同事。 – ppseprus 2013-04-28 15:16:21