Monday, April 16, 2007

HDD failure hassles

So, I had a little HDD failure on my desktop at home. Not unheard of, at least I was able to scp all my important files off it. Problem I now had, was that all my photos had a creation date of today! This does not play well with my applications like Picasa.

Lucky for my is that Phil Harvey is a smart and generous person: he created exiftool and gave it to the world! This enabled me to write this little script to modify the date of all my image files to the data provided in the standard EXIF data.

for f in $(/usr/bin/find . | egrep -i "\.jpg"); do echo "$f"; SNAP_DATE=`exiftool "$f" | egrep "^Create Date" | awk '{print $4,$5}' | sed 's/ //g;s/://;s/://;s/://;s/:/\./' | awk '{print substr($1, 1, 15)'}`; echo "$SNAP_DATE -> $f"; touch -t $SNAP_DATE "$f"; done
Thanks Phil...

No comments: