2009-11-23 22 views
0

我正在構建一個Applescript滴以自動執行某些操作。我有以下行:在Applescript中存儲告訴Finder操作的返回引用

tell application "Finder" to duplicate dropped 

丟棄被丟棄在液滴上的文件的引用。該文檔說,這將返回對重複對象的引用。

我想將myVariable設置爲返回的引用,但我無法在任何文檔中找到如何實際執行該操作!

回答

1

,如果它是一個液滴的新位置,請注意,該參數是別名列表(你可以拖動一個以上文件!),並且如果您複製單個發現者項目,您將獲得一個發現者項目,而如果您複製多個發現者項目,則會得到一個查找器項目列表。即重複的返回值取決於發送給它的參數。

AND ...取景器項目在取景器外面並不是很有用。你最好用別名或POSIX路徑。

所以你可能需要像

on open (dropped) 

tell application "Finder" 
    set duplicate_Finder_items to duplicate dropped 
end tell 

-- convert the Finder reference for each duplicate item to an AppleScript alias 

set duplicate_item_aliases to {} 

if class of duplicate_Finder_items is list then 
    repeat with i from 1 to number of items of duplicate_Finder_items 
     set the end of duplicate_item_aliases to (item i of duplicate_Finder_items) as alias 
    end repeat 
else -- result was a single Finder item, not a list 
    set duplicate_item_aliases to {duplicate_Finder_items as alias} 
end if 

repeat with f in duplicate_item_aliases 
    set inf to (info for (f as alias)) 
    set n to name of inf 
    display dialog "You duplicated a file. The duplicate is now known as " & n 
end repeat 

月底開放

0

duplicate命令允許用於待指定的位置:

set theResult to duplicate reference ¬ 
    to insertion location ¬ 
    replacing boolean ¬ 
    routing suppressed boolean 

參數,必需,類型,說明

直接參數的,必需的參考,對象(s)to duplicate

替換,可選的,布爾,指定是否要替換目的地具有相同的名稱的項目被複制

路由抑制,可選的,布爾項目,指定是否要自動撥號項目(默認爲false)。僅在複製到系統文件夾時適用。

,可選,插入位置,對象(或多個)