found drama

get oblique

Automator: still a little lacking?

by Rob Friesel

Apple’s Automator has been a mixed bag for me since its release in 2005 1.  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 2.  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 3 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:

  1. Aperture: Get Selected Images
  2. 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 4 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 AppleScript:

The Automator action:

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

  1. With OS X 10.4 “Tiger” – rawr![]
  2. After an inexplicable delay of several seconds while Finder and/or Automator gets itself into first gear…[]
  3. Or at least inaccessible to anyone that didn’t already think of themselves as developers.[]
  4. ”4Uploadr” = for Uploadr; get it?.[]
  5. 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.[]
  6. 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.[]

About Rob Friesel

Software engineer by day. Science fiction writer by night. Weekend homebrewer, beer educator at Black Flannel, and Certified Cicerone. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

Leave a Reply

Your email address will not be published. Required fields are marked *