2014-04-02 83 views
2

創建使用AppleScript

set folder_1 to text returned of (display dialog "Create Folders:" default answer "Type Here") 
set folder_2 to "new_" & folder_1 

set loc1 to ":path1" 
set loc2 to ":path2" 


tell application "Finder" 
    set newfo1 to make new folder at loc1 with properties {name:folder_1} 
    make new folder at newfo1 with properties {name:"new folder"} 
    make new folder at newfo1 with properties {name:"new folder"} 
    make new folder at newfo1 with properties {name:"new folder"} 
    make new folder at newfo1 with properties {name:"new folder"} 

    set newfo2 to make new folder at loc2 with properties {name:folder_2} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 
    make new folder at newfo2 with properties {name:"new folder"} 

make alias at folder_1 to folder_2 

end tell 

任何人可以闡明在上面的代碼創建別名光的搜索別名。我試圖在{name:folder_1}內部創建一個{name:folder_2}的別名,但使用該變量我得到了一個Finder got an error: AppleEvent handler failed。任何人都可以幫忙嗎?

非常非常感謝

回答

1

看起來像所有你需要做的是改變你的make alias語句中使用新創建的文件夾對象

make alias at newfo1 to newfo2 

請注意,您的代碼不處理你創建的任何文件夾已經存在的情況下(在這種情況下你會得到error "The operation can’t be completed because there is already an item with that name." number -48)。

+0

啊,謝謝。是的,這是一種享受。讓我的頭繞着條款,歡呼。 – stuart