noisybox.net blog | photos | computers | art | electronics | misc | to_do | links | resumé | email

weblogs tagged hack RSS feed

Viewing entries 1 to 1 [1 matching items]
author
Quickie perl hack to fix up image timestamps with Exif data
Tuesday, October 21st 2008 10:34pm
Tags: perl hack exif image timestamp

canon

Ooops! I've been organizing image files recently from my camera and realized that I was losing timestamps when moving them to a remote Samba share. Fortunately, image formats and cameras these days are smart enough to embed the original timestamp inside the image itself (assuming you have a moderately recent camera and assuming you've gone thru the process of configuring the date/time).

I hacked up the almost trivial perl script below to touch each file with the data from the exif data.

----------
#!/usr/bin/perl
# Touch files with Exim timestamps
use strict;
foreach my $f (@ARGV){
    my $d = `jhead $f | grep 'Date/Time'`;
    chomp $d;
    $d =~ s/^Date/Time.*: (d+):(d+):(d+) (d+):(d+):(d+)/$1$2$3$4$5.$6/;
  `touch -t "$d" "$f"`;
}

----------

The script depends on the jhead tool to get the data from the image, but the rest is dead simple.

blog | photos | computers | art | electronics | misc | to_do | links | resumé | email
all content, text, images, sounds, software, code, ideas © 2008 jason plumb / noisybox / infiltration lab. email