An Apple iBook For Dad Display AppleSwitcher (or any) RSS as a screensaver
Mar 14 2006

If you download to your desktop like I do it probably looks like a junk pile half the time.

If you’ve got Mac OS X 10.4 you can do something about it with a combination of Apple’s Folder Actions and Automator. If you don’t have OS X 10.4, you can achieve these results, but you’ll have to use AppleScript.

This tutorial will show you how to tailor my short Automator Action to your needs, and how to attach it to a Folder Action.

Download

Download this zipped Automator workflow. I created it as a starting point for you to build off of.

Please Note OS X 10.5’s Automator is a bit different than 10.4’s. When you run the downloadable script, you’ll see a warning dialog box outlining the differences that exist in this workflow. Keep in mind you’re working with a 10.4-era workflow. Use at your own risk. That said, it should work the same.

Automator File Types

Two notes about Automator’s files:
1. An Automator workflow is a file that by itself cannot do anything. It’s akin to source code of an HTML file — you’re looking at what makes it work, but not running (”executing”) it. Open the workflow in Automator so that you may edit it.

2. If you save an Automator workflow as an application the result is “live” and will do whatever you’ve configured it to do if you double click it, or have it triggered by an OS process like an AppleScript, etc. In this respect it’s similar to a droplet in Photoshop, for those of you versed in Adobe’s flagship image editing application.

Unpack and Save

For this tutorial, unpack the .zip, open it with Automator, and Save As a Plugin because in 10.4 Folder Actions are neatly tied to Automator Applications via this option.

In the Save As dialog, name it something like “testing”, then select Finder in the “Plug-in for” dropdown. That thoughtfully puts it in

in 10.4:

/Users/[username]/Library/Scripts/Folder Action Scripts

in 10.5:

/Users/[username]/Library/Workflows

Set Up the Folder Action

Now go to a finder window, right-click (or Control-click) Desktop, ensure Folder Actions are enabled, and select “Attach a Folder Action…”

The Choose a File dialog box should open right to the Folder Action Scripts folder where you’ve just saved your Automator Plugin. Select the Plugin you just created. This is where the marriage happens between Automator and Folder Actions.

It’s Ready

Now when a file is dropped into your Desktop folder — from anywhere or anything — the Desktop Scrubber will activate. If the dropped file meets the criteria, it will be processed. If not, nothing will happen to any file.

In either case you’ll see a brief activity icon in OS X’s menu to let you know the script is activating. You may attach many Folder Actions to one folder.

Here’s Where You Come In

I think this goes without saying, but I want to cover all bases so here goes. There are an infinite number of variations you may make to the Desktop Scrubber workflow you downloaded to customize it. In its current state it probably won’t do a thing, unless you have files with “whatever” in their name on your Desktop. Unlikely.

To really make something happen, in the third step of the workflow, replace “whatever” with part of the file name you want the process to act on. In other words, if you download many files that have “_db” in their name like I do when I back up this site’s forum, put “_db” there. Same holds true for extensions (as opposed to Name Contains) like .pdf, or .html, or .wmv. This is where you tell Automator how to identify the files it should process.

If you want it to act on all files that find their way to your Desktop, then delete that step altogether.

Likewise, you may want to have this process attached to any number of folders, and not necessarily the Desktop. You may or may not want to have the date appended to the files’ names (step 4). Etcetera, etcetera. This workflow is meant only to be a starting point for you.

Get creative; there’s so many ways to save time with Folder Actions that you may end up with a very elaborate set of them. I did when I discovered the beauty of combining them with Photoshop Actions. For instance, because an Action can save a file to a folder that has a Folder Action attached, I automated every step of my post-Photoshop corrections.

In Photoshop I’d color-correct, then crop images. Then I’d hit a F-key to trigger a Photoshop Action that would Save for Web into a certain folder. That folder would have a Folder Action attached that would trigger an AppleScript (a topic for the next tutorial) that would have Transmit FTP client move the .jpg up to a folder on my website. From Photoshop to Web in 8 seconds.

When you’re ready to test your new customized workflow, click Automator’s Run button. But beware, files will really get renamed, moved, and whatever else you’re having Automator do to them. Start slow.

Conclusion

When your Automator action is ready to be pressed into service, go back to this tutorial’s beginning where you Save As a Plugin, and repeat the steps with your new Action. Save the workflow as a Workflow in Documents or somewhere similar. You may go back to that workflow to tweak it and save as a Plugin again. Simple, no?

Etcetera

Apple offers many prewritten Automator Actions for free download.

I welcome comments on this tutorial. I’ve revised it three times, (Feb. 2007) for improvements in legibility, (Nov. 2007) for OS 10.5 Leopard updates and to fix the download link, and (Jan. 2008) to add the Leopard Save As download path [thanks Jay].

12 Responses to “Automator and Folder Actions Tutorial”

  1. Folder Actions for OS X explained - with real-world examples - Simplehelp Says:

    […] Use Folder Actions and Automator to keep your Desktop super-clean […]

  2. sabor Says:

    Thanks for the tutorial, I have downloaded your workflow and tailored to my needs. I had no idea you could attach Automator workflows to folders, this is too cool!!

  3. mike Says:

    thanks do much for this tytorial; very helpful. cheers.

  4. meer Says:

    Is the workflow still available? The link to download is no longer active.

  5. Matt Says:

    Zip file is back up. Sorry for the inconvenience!

  6. AppleSwitcher Forum | More Free photoshop tutorials,resources and news Says:

    […] Forum Posted in January 3rd, 2008 by adobeperson in Photoshop News AppleSwitcher Forum … (a topic for the next tutorial) that would have Transmit FTP client move the .jpg up to a […]

  7. Jay Says:

    Adapting for Leopard, the “Save As Plug-in” puts it in User/Library/Workflows/ … .

  8. Matt Says:

    Revised. Thanks Jay!

  9. Wassim Says:

    I cannot choose the automator workflow I have created as a Folder Action. It is greyed out. Any idea why? Thank you.

  10. Alex Says:

    Matt, could you please update this great tutorial for Leopard? There appear to be some differencies in the way of interaction between Automator workflows and Folder Actions in 10.5.
    TIA

  11. Alex Says:

    Nevermind, there appears to be an option to save file as a plug-in for Folder Actions in Leopard.

  12. Rafa Says:

    damn. For some reason it does not work on Mac OS X 10.4.11.
    Saving as Fodler Action Plug-In saves the file under ~/Library/Workflows/Folder Actions/ not under Scripts, and saves it as an Application, actually. Finder seems to be expecting a .scpt file because if I look into “Configure Folder Actions”, my “action” will appear associated to the folder but with a .scpt extension (which doesn’t exist; the file I mean) and clicking on “Edit Script” does nothing.

    Also to note, when I do “saves as plugin” in Automator, by default it has “folder action” selected, but the drop-down menu where you choose which folder to link it to is *not there*! To get that dropdown menu tu appear, I have to re-choose “folder action” as the type of plug-in that I want, then the folder drop-down menu appears.

    So, in the end, when I drag a file to my chosen folder, nothing happens–at all.

    Weird.

    I am using OSX 10.4.11, and Automator 1.0.5 (88.2), in Spanish (I wonder if this has something to do with it).

    Update: I have just run Automator in English (disabling the Spanish language from the Finder) and the result is the same.

Leave a Reply