I recently shot a wedding with three cameras and was then given a few photographs from others to work into an album, shots I couldn’t have taken as I was on route to the church. One issue has raised it’s head. Time and Date. My cameras were reasonably in sync, but not perfect. Some of the wedding party had cameras that weren’t even in the same day! When it comes to merging them into a time sorted set in Lightroom the pictures out of place become an issue when trying to layout an in sequence book.

Perl to the rescue again! I’ve written two quick command line tools using Phil Harvey’s Image::ExifTool module. They will run from a Linux, Mac or Windows system. For Windows you’ll need the free Perl build from ActiveState.

The first is EXIF-Get.pl. Run from a command prompt passing the file name as the first parameter. It will return the date and time. E.g.
C:\> EXIF-Get.pl IMG_4555.JPG
2010:07:31 15:50:27

use Image::ExifTool;
$file=$ARGV[0];
my @ioTagList = ("DateTimeOriginal");
my $exif = new Image::ExifTool;
$exif->Options(DateFormat => "%Y:%m:%d %H:%M:%S");
my $info = $exif->ImageInfo($file, @ioTagList);
my $datetime = $$info{"DateTimeOriginal"};
print $datetime . "\n";

The second is EXIF-Set.pl, this time given an extra date time parameter in quotes. E.g.
C:\> EXIF-Set.pl IMG_4555.JPG “2010:07:31 15:50:27”

use Image::ExifTool;
$file=$ARGV[0];
$datetime=$ARGV[1];
my $exif = new Image::ExifTool;
my $info = $exif->ImageInfo($file);
$exif->SetNewValue(DateTimeOriginal => $datetime, Protected => 1);
$success = $exif->WriteInfo("$file");

If you’re using Lightroom and have edited the image make sure you pick “Metadata -> Save Metadata to File” before you use the tool to ensure all of the editing information is saved. The tool reads all meta data in before updating the DateTimeOriginal tag and writing it all back out.