1

所以我有这个 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 个项目时,它会在目标文件夹中为这两个项目创建别名。

附带说明一下,有什么方法可以让它在您运行它的时间之间记住源文件夹和目标文件夹?

4

1 回答 1

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
于 2012-10-02T16:56:25.043 回答