Run Automator when new file is added

I would like to move a file to a folder hierarchy based on file extension every time a file is downloaded to the downloads folder. I have created some Automator scripts to do this, but I think there might be a better way?

I posted this thread http://discussions.apple.com/thread.jspa?threadID=2455708&tstart=0 and they recommended me to come here. Any thoughts?

2.4GHz Intel i5 15" Laptop, Mac OS X (10.6.3), 4GB 1067MHz DDR3

Posted on Jun 9, 2010 9:32 PM

Reply
3 replies

Jun 10, 2010 11:24 AM in response to nZac

Here's a very simple example of what can be done with AppleScript:

*on adding folder items to this_folder after receiving added_items*
try
*tell application "Finder"*
*set myDesktop to path to desktop folder as text*
*repeat with thisFile in added_items*
*set X to name extension of thisFile*
*if X is "rtf" then*
*move thisFile to folder (myDesktop & "A")*
*else if X is "webloc" then*
*move thisFile to folder (myDesktop & "B")*
else
*move thisFile to folder (myDesktop & "C")*
*end if*
*end repeat*
*end tell*
*end try*
*end adding folder items to*

If you attach the above script to your Downloads folder and create three new folders on your desktop, respectively named "A", "B" and "C", then any file added to your Downloads folder should be moved to one of these three folders, depending on its file extension.

In order to attach the script to your Downloads folder, just save it to the “Folder Action Scripts” folder (/Library/Scripts/Folder Action Scripts); then double click the “Configure Folder Actions” alias located in the “Folder Actions” folder (/Library/Scripts/Folder Actions).

Hope it can help.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Run Automator when new file is added

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.