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.

# 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.

this is a blog permalink

Want to go to the current blog?