Apple脚本:将文件移动到适当的文件夹

时间:2013-02-27 01:32:52

标签: applescript filenames move

我是Apple Script的新手,我希望得到一些帮助来完成这个简单而冗余的任务。

假设我有一个包含这些文件夹的文件夹

贾巴 富 大不了

我希望将文件放入此文件夹,并让它自动按文件名对4个选项中的1个进行排序。 如果文件名包含jabba转到Jabba文件夹,如果foo然后Foo文件夹,...如果没有,请不要做任何事情离开它。

由于

我有OSX 10.7.5

1 个答案:

答案 0 :(得分:1)

尝试:

on adding folder items to theFolder after receiving theFiles
    repeat with aFile in theFiles
        tell application "Finder"
            if aFile's name contains "Jabba" then
                move aFile to (first folder of theFolder whose name = "Jabba")
            else if aFile's name contains "Foo" then
                move aFile to (first folder of theFolder whose name = "Foo")
            else if aFile's name contains "Biggie" then
                move aFile to (first folder of theFolder whose name = "Biggie")
            end if
        end tell
    end repeat
end adding folder items to