StudentOfScience
StudentOfScience

Reputation: 809

Apple Script: Move files to appropriate Folder

I am fairly new to Apple Script and I was hoping to get some help doing this simple but redundant task.

Lets say I have a folder that has these folders

Jabba Foo Biggie

and I want to drop files in to this folder, and have it automatically sort 1 of 4 options by just file name. If file name contains jabba go to the Jabba folder, if foo then Foo folder, ... if none, don't do anything leave it be.

Thanks

I have OSX 10.7.5

Upvotes: 1

Views: 552

Answers (1)

adayzdone
adayzdone

Reputation: 11238

Try:

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

Upvotes: 1

Related Questions