AppleScript用于在文件夹中创建文件别名

时间:2012-10-02 15:45:06

标签: applescript finder aliases

所以我有这个AppleScript用于将一个文件夹的所有内容的别名制作成另一个文件夹。

除非源文件夹中只有一个项目,否则我的工作完美。

tell application "Finder"
    set SourceFolder to (choose folder with prompt "Please choose Source folder:") as string
    set DestinationFolder to (choose folder with prompt "Choose Destination folder for aliases:") as string
    set theFolders to every item of entire contents of folder SourceFolder
    repeat with thisFolder in theFolders 
        set thisName to name of thisFolder
        make new alias file at folder DestinationFolder to thisFolder without invisibles
    end repeat
end tell

知道为什么只有一件物品才能得到任何东西?如果源文件夹中至少有2个项目,则会在目标中为两者创建别名。

在旁注中,在运行它之间的任何方式让它记住源文件夹和目标文件夹?

1 个答案:

答案 0 :(得分:0)

尝试:

property SourceFolder : missing value
property DestinationFolder : missing value

if SourceFolder = missing value then
    set SourceFolder to (choose folder with prompt "Please choose Source folder:")
    set DestinationFolder to (choose folder with prompt "Choose Destination folder for aliases:")
else

    tell application "Finder"
        set theFolders to every item of entire contents of SourceFolder as list
        repeat with thisFolder in theFolders
            make new alias file at DestinationFolder to thisFolder
        end repeat
    end tell
end if