AppleScript覆盖或跳过命令?

时间:2013-11-09 01:50:06

标签: applescript finder

我有以下带有文件的AppleScript并将它们放在相应的文件夹中。

set sourceFolder to choose folder

tell application "Finder"
set theFiles to files of sourceFolder

repeat with aFile in theFiles
    set fileName to name of aFile

    if fileName contains "#" then
        set poundOffset to offset of "#" in fileName
        set folderName to text 1 thru (poundOffset - 2) of fileName

        set newFolder to (sourceFolder as text) & folderName & ":"
        if not (exists folder newFolder) then
            make new folder at sourceFolder with properties {name:folderName}
        end if

        move aFile to folder newFolder
    end if
end repeat

告诉

除非发生文件冲突,否则它对我很有用。如果文件夹中有一个同名的文件,它将它放入脚本中会出错并崩溃。所以我的问题是这个....我该如何解决这个问题?我愿意它只是覆盖文件,但有没有办法提示跳过文件或只是跳过它们并继续下一个?

我在这里可以做的事情上有点模糊。在此先感谢您的帮助。

Ringslinger。

1 个答案:

答案 0 :(得分:0)

尝试:

move aFile to folder newFolder replacing true