beyondmac.com|comments, answers, etc.

Home Contact About Subscribe(RSS)

The Book:

Buy Mac OS X Leopard: Beyond the Manual from Amazon, or check out the Apress website for more information.

Categories:

Bookmarks:

Powered by WordPress

Renaming Images Using EXIF Data | October 30, 2007

For years I’ve been using the excellent ExifRenamer to rename my digital photos when I imported them by setting it up as the Automatic Task in OS X’s Image Capture application. When Aperture came out I tried using its built in renaming feature, but found it to be inflexible (and while subsequent updates have improved this feature, the “Time” value still adds unnecessary, unwanted “-”’s). Rather then start a whole new naming scheme after years and years I continued to use ExifRenamer with the Image Capture application.

Note: Until recently I never really used iPhoto. Prior to Aperture I would use iView Media Pro, which has subsequently been gobbled up by Microsoft and is now known as Expression Media , to manage all my photos. So the extra step involved using Image Capture rather then importing directly into Aperture never bothered me that much.

The thing is ExifRenamer hasn’t been updated since 2002, so I’ve been looking for a way to duplicate this function without added steps in my workflow. Other then ExifRenamer, I’ve found that most GUI based utilities tend to do more then I’d like, the thing about ExifRenamer is it did one thing very easily and extremely well, everything else I’ve found suffers from feature creep (though if you want to rename you images to something other then  just EXIF timestamps, then A Better Finder Rename is definitely worth a look). Anyway after much searching, I realized that the answer was already right under my nose: ExifTool by Phil Harvey.

ExifTool is a Perl Module (Image::ExifTool) which comes complete with a command line tool (exiftool) that can do almost anything you want done with EXIF data. I had to use this once a while ago when I realized that the new (at the time) editing tools in iView Media Pro were overwriting the original EXIF dates (which nothing should ever do, no matter what the developer says) and I needed to change them back and this tools fit the bill. Turns out, that this tool is perfect for renaming files based on EXIF data too (in fact it can rename files, and move them in directories based on *any* EXIF data).

For my purposes, the exact exiftool command I want to run on each image is:
exiftool ‘-filename<CreateDate’ -d %Y%m%d_%H%M%S%%+c.%%e $x
In this command, ‘-filename<CreateDate’ actually does the renaming (passing the CreateDate to the filename). -d %Y%m%d_%H%M%S%%+c.%%e defines the format of CreateDate using strftime (see man strftime for info).  (The %%+c.%%e (which add a file counter and the proper file extension) however are part of exiftool, not strftime (which is why they get two %’s, if you just used one % then you would use strftime‘s %c and %e which is not what we want).) $x is a variable which represents the original image file.

To be able to execute this command from Image Capture, I need to wrap this command inside of an Automator Application. So I open Automator and create a new workflow. My first action is simply “Get Selected Items” which will take the Finder items passed to the workflow and pass it to the next action. My second (and last) action is “Run Shell Script.”

For the Run Shell Script action set the Shell: to /bin/bash and Pass input: “as arguments.” Then in the script area input the following script:

for x in "$@"
do
exiftool '-filename<CreateDate' -d %Y%m%d_%H%M%S%%+c.%%e $x
done

Now save your Automator workflow as an Application and use it in Image Capture or on it’s own (By dragging images on it to use).

And That’s it.

1 Comment »

  1. [...] while ago I wrote this post about how to rename images using EXIF data, and in it I lamented the fact that this was only [...]

    Pingback by beyondmac.com » Blog Archive » ExifRenamer Updated! — December 8, 2007 @ 7:18 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment