0

我有以下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

结束告诉

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

我对我能在这里做什么有点模糊。在此先感谢您的帮助。

吊环。

4

1 回答 1

0

尝试:

move aFile to folder newFolder replacing true
于 2013-11-09T02:49:11.500 回答