Automating image imports with exiftool

For years I’ve been using Shotwell as my image manager of choice, but in the last 18 months or so it’s become increasingly difficult (nee impossible) to compile on non-bleeding edge stable Linux releases such as CentOS 6 (which happens to be my choice of desktop).

I tried, and failed, to get along with Digikam, gThumb, Darktable and a host of others – many non-maintained. They were almost all single user, except web-based DAM solutions, which were massively overweight for my use case. For completeness, the primary use case was “allow me and my wife to dump photos from SD cards/phones/tablets etc to somewhere safe, indexed by date, and backed up”.

I’d already created a share on my home NAS into which we could both dump images, but a side-effect of long term use of Shotwell was that the images were copied over to a YYYY/mm/dd directory structure and with 500GB+ I did not want to have to reindex that if I could help it.

Google didn’t seem to want to help me, until I started searching for terms like “import photos based on EXIF data”, and then…

I found a nugget of beautiful information: ExifTool (written in Perl) could do the hard bit, importing, for me!

So to save you the trouble, here’s the code:

#!/bin/sh

/usr/bin/exiftool -r -P -v0 -if '$filename !~ /(^\.)/' \
   "-Directory<FileModifyDate" \
   "-Directory<DateTimeOriginal" \
   -o no-date-available/ \
   -d "/mnt/imagedir/%Y/%m/%d" \
   "/mnt/photodrop"

Essentially, it boils down to:

  • ignore files beginning with a period
  • select target directory based on EXIF date, or date modified depending which is available
  • put them in a YYYY/mm/dd directory structure

And that’s it. Perfect. Dead simple, agnostic of editor, properly multi-user and indexed by date.

Advertisements

2 comments

  1. Pingback: Google Drive – data sync with gsync « Random Ramblings


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s