Apple’s Automator has been a mixed bag for me since its release in 2005[]. 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 split[]. 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 impossible[] 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 4Uploadr[] 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>”[]. 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.
Unsatisfactory!
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 AppleScript:

That’s:
tell application "Finder"
if "Malkovich:Users:rob:Desktop:4Uploadr" exists then
return true
else
make folder at desktop with properties {name:"4Uploadr"}
end if
end tell
The Automator action:

Sure enough, it worked. It creates the folder if it’s not there[], 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.