Use folder actions to manage downloaded images

Oct 30, '03 10:15:00AM

Contributed by: adrick42

I had heard a lot about Folder Actions, but after searching a lot of the script archives, I couldn't find anything really useful. I thought a good use for Folder Actions would be to decrease Desktop clutter, so I wrote this script to maneuver any image files (based on the extension) into an "unfiled" folder in the ~/Pictures directory.

All that you have to do is copy and paste the following text into ScriptEditor, save it as a .scpt file, then apply a folder action to your downloads directory, and voila!

on adding folder items to this_folder after receiving added_items
  tell application "Finder"
    repeat with aFile in added_items
      if the name of aFile contains {".jpg"} ¬
       or the name of aFile contains {".gif"} ¬
       or the name of aFile contains {".png"} ¬
       or the name of aFile contains {".pict"} ¬
       or the name of aFile contains {".tiff"} ¬
       or the name of aFile contains {".gif"} ¬
       or the name of aFile contains {".psd"} ¬
       or the name of aFile contains {".bmp"} then
      tell application "Finder"
        try
          move aFile to folder "Mac_name:Users:User_name:Pictures:unfiled:"
          on error err
            display dialog err
         end try
       end tell
       display dialog ¬
       "Image files have been moved to the Unfiled folder in your Pictures folder."
     end if
   end repeat
  end tell
end adding folder items to
Hope you enjoy!

[robg adds: Folder actions were originally discussed in this hint, and there have been a number of hints since then which put them to use. In Panther, the interface for Folder Actions has been greatly improved (I found the 10.2 version very confusing!), so hopefully we'll see even more examples putting them to good use.]

Comments (16)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20031026201131160