on adding folder items to this_folder after receiving these_items tell application "Finder" repeat with this_item in these_items try set this_type to the kind of this_item as string tell me if (this_type is "Folder") then processFolder(this_item) else processFile(this_item) end if end tell on error err display dialog (err as string) end try end repeat end tell end adding folder items to on processFolder(this_folder) tell application "Finder" set these_items to every item in this_folder if the (count of these_items) is 1 then repeat with this_item in these_items try set this_type to the kind of this_item as string tell me if (this_type is "Folder") then processFolder(this_item) else processFile(this_item) end if end tell on error err display dialog (err as string) end try end repeat end if end tell end processFolder on processFile(this_file) set new_folder to (path to home folder as string) & "Inbox:" tell application "Finder" if (the name of this_file ends with "dmg" or the kind of this_file is "Installer package" or the kind of this_file is "Application") then set new_file to new_folder & "Apps:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Apps:" else delete this_file end if else if (the name of this_file ends with "doc" or the name of this_file ends with "xls" or the name of this_file ends with "ppt" or the name of this_file ends with "pdf") then set new_file to new_folder & "Docs:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Docs:" else delete this_file end if else if (the name of this_file ends with "mp3" or the name of this_file ends with "aac" or the name of this_file ends with "m4a" or the name of this_file ends with "m3u") then set new_file to new_folder & "Music:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Music:" else delete this_file end if else if (the name of this_file ends with "avi" or the name of this_file ends with "mov" or the name of this_file ends with "mp4" or the name of this_file ends with "mpg" or the name of this_file ends with "mpeg") then set new_file to new_folder & "Movies:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Movies:" else delete this_file end if else if (the name of this_file ends with "jpg" or the name of this_file ends with "jpeg" or the name of this_file ends with "gif" or the name of this_file ends with "png" or the name of this_file ends with "bmp") then set new_file to new_folder & "Images:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Images:" else delete this_file end if else if the name of this_file ends with "html" then set new_file to new_folder & "Web Pages:" & the name of this_file if not (exists new_file) then move this_file to new_folder & "Web Pages:" else delete this_file end if end if end tell end processFileYou'll need to adjust your folder structure accordingly, but that's the gist of it.
else if statements; it just makes new folders for filetypes it hasn't seen before.
I think Hazel will do this for you.
posted by Armitage Shanks at 10:15 AM on September 20, 2007