Automator is incredibly powerful, but at the same time the most useless and semi-functional piece software I've ever encountered. I recently built my first Automator Workflow to watermark a PDF. I wanted to load selected PDFs from the Finder, and for each PDF create a file in the same directory with a -watermark suffix appended. file1.pdf and file2.pdf would yield file1-watermark.pdf and file2-watermark.pdf.
It took me much too long to figure out that it wasn't easy (or maybe even possible) with Automator, even though it's simple to do from the command line.
Each Automator action returns a result. That result is passed to the next item in the chain, assuming the item is accepting input. The key is to chain a series of Get Value of Variable calls together, which are passed to a shell script as $1-$n and the special $@ variable. I've written a short primer on using Arrays in Bash that may be helpful.
A crappy picture is worth at least 68 words, so here is what a sample workflow looks like:

You can download the sample workflow here.
If you want to loop through selected Finder items one-at-a-time, the best way is to use Nyhthawk Productions's excellent Dispense Items Incrementally action.
Tags: Apple, AppleScript, Automator, OS X



February 23rd, 2011 at 7:34 am
Hi Corey–
A very helpful tutorial. I'm trying to put an automator flow together and this was just what I was looking for. Just thought I'd mention that the the sample download doesn't have the correct permissions set. I get an access denied error. Thanks!
February 27th, 2011 at 5:11 pm
This is indeed helpful, but I am trying to use two file names in the same line of the script:
pdfdiff.py -d opendiff A.pdf B.pdf
It is not clear how to do that. Should I be doing:
pdfdiff.py -d opendiff "$1" "$2"?
Also, the sample download does not work for me either as the permissions are not set.
Thanks much.
March 2nd, 2011 at 11:24 am
Very helpful. I am now able to set the input to the path of a folder and then its file list.
July 10th, 2011 at 7:32 am
@tamer Yes – $1 and $2 will represent the first two variables presented.
Quoting them ensures that they are kept each as a single argument even if they contain spaces.
Anyway – this was quite helpful. It is a bit of a shame that automator variables are not simply exposed as environment variables for the scripts (rather like the parameters in jenkins) – that would be kind of awesome.