Code and Stuff

Apr 26, 2010

F-Spot date fix

One of the things I find quite annoying in f-spot is that dates you set manually are not stored into the exif metadata of a jpeg picture. There is probably a way to do this, some setting in f-spot or something, but I didn't find it.
So here is a very simple way to commit the dates to the jpeg's exif.
WARNING: make sure you have a copy of your photos.db file and of all your pictures. This script has NOT been tested extensively, use at your own risk!

#!/bin/bash
sqlite3 ~/.config/f-spot/photos.db "SELECT * FROM photos" | while read line; do
   epoc=`echo $line | cut -d \| -f2`
   base=`echo $line | cut -d \| -f3 | sed -e "s%file://%%"`
   file=`echo $line | cut -d \| -f4`
   time=`date --date "Jan 1, 1970 00:00:00 +0000 + $epoc seconds" +"%Y:%m:%d-%H:%M:%S"`
   jhead -ts$time $base$file
done