Apple’s AutomatorÂ has been a mixed bag for me since its release in 20051. Â For renaming a wad of files, it has been great: Â select them, invoke Automator, and seconds later they’ve all been renamed to conform to the convention you had in mind. Â Exported charts from Excel too large? Â Pass in those files and Automator can scale those down lickety split2. Â But if you want to get much more complicated than that… Â Well, you might be out of luck.
But with OS X 10.5’s release, Automator got a few useful additions to make it a bit more useful. Â In particular, support for variables added some flexibility that was previously impossible3 within the framework it provided. Â So I decided to throw a little task at Automator:
Take my selected photos and export them to a folder on the Desktop called “4Uploadr” (and create that folder first if it isn’t already there).
Straightforward enough, eh? Â So I dropped in two actions:
- Aperture: Get Selected Images
- Aperture: Export Versions
- Destination: (Variable = ~/Desktop/4Uploadr)
- Export Preset: JPEG – Original Size
- Export Name Format: Current Version Name
- Export subfolder: No folder…
Which I naÃ¯vely believed would do the trick. Â Wouldn’t Automator know that if 4Uploadr4 didn’t exist that it was supposed to create it? Â Nope. Â It just quietly fails, recording in the Automator log that such a folder does not exist. Â Alright, what about setting “Export subfolder” to “Custom”? Â No, that only appears to output the selected images into a folder with the name “<untitled>”5. Â Perhaps there is a preference buried somewhere in there for setting “Custom” to “something useful” instead of “<untitled>” â€” but if it’s in there, I couldn’t find it.
So instead: Â AppleScript to the rescue!
One of the variables that Automator now accepts/supports is an “AppleScript” variable wherein you set a script for Automator to execute. Â In my case, I wrote a script to test for the existence of “4Uploadr” and the create it as necessary before exporting all those images from Aperture into it.
The Automator action:
Sure enough, it worked. It creates the folder if it’s not there6, passes through quietly if it is there and then exports all the selected images from Aperture just like we would want. A little heavier lifting than originally expected but nothing too terrible.
- With OS X 10.4 “Tiger” â€” rawr! [↩]
- After an inexplicable delay of several seconds while Finder and/or Automator gets itself into first gear… [↩]
- Or at least inaccessible to anyone that didn’t already think of themselves as developers. [↩]
- ”4Uploadr” = for Uploadr; get it?. [↩]
- In theory, this should be OK. Â At least it appears to consistently put the images here. Â But this isn’t what I want; and I fully intend to get exactly what I want. [↩]
- Which is a wholly separate rant consisting mostly of how (1) it’s entirely too difficult to test for falsy values in AppleScript and (2) how AppleScript makes it unnecessarily hard to create that folder. “Like plain English” my ass. [↩]