Fixing photo dates

Let’s say, just for argument’s sake, that when you got that new camera shortly after the first of the year, you mistakenly set its clock to the year 2008 instead of 2009. So now you have a bunch of photos with screwed-up metadata. What to do?

The first thing to do is download and install Phil Harvey’s extensive ExifTool system. ExifTool is a Perl library with a command-line application that can do all kinds of reporting and surgery on the metadata in your image files. Mac users can install ExifTool using either the Mac instructions (which install from a package) or the Unix instructions (which install through a Makefile). I chose1 the Unix installation so I’d have standard access to the libraries if I wanted to write my own programs. One thing I didn’t like about the installation was that it put the exiftool command-line program in /usr/bin, which I think should be reserved for Apple-supplied programs. After following Harvey’s instructions, I also did

sudo mv /usr/bin/exiftool /usr/local/bin/

which moved exiftool to a more suitable directory. There’s probably nothing wrong with the standard installation; this is just my preference.

With exiftool installed, navigate to the directory where your mistakenly-dated photos are and execute

exiftool '-AllDates+=1:0:0 0:0:0' *.JPG

This adds (+=) one year to all the date values (-AllDates) in the metadata for every .JPG file in the directory. The time shift is in the format

years:months:days hours:minutes:seconds

There are some shortcuts you can use if you just need to adjust the hour value--after a vacation in a different time zone, for example, or a shift to/from Daylight Saving Time.

Considering how little it seems to be doing, ExifTool runs rather slowly. That’s because it makes a backup copy of every file before changing the metadata. You’ll find the backups in the same directory as the originals, with an _original extension. If the metadata editing goes wrong, you can restore from these backups. This is a nice feature, but I still prefer to make backups before editing my photos.

ExifTool changes the metadata in the JPEG file itself. I’m not a big user of iPhoto, but it’s my understanding that it reads file’s metadata when the photo is imported, then uses its own copy of that data when displaying dates. So if you’ve already put the mistakenly-dated photos into iPhoto, you may need to move them out of iPhoto, change their dates, and then reimport them. Whatever you do, make sure you have backups before doing anything that might affect your precious photographs.

Tags:


  1. Oh, wait! This was supposed to be a hypothetical discussion, wasn’t it?