SQL magic
I use F-Spot to organize my photo collection. In Ubuntu 7.04, F-Spot gained the ability to import photos from your camera to other locations than the default ~/Photos. So it would be really nice to now get all the photos into the new location, right? Problem is, the photo database (~/.gnome2/f-spot) joins the photo tags with photo path and file name; Moving the files would mean losing all the tags. Bad idea if you can identify all your friends by the photo tags…
Now, F-Spot uses an SQLite database. So we can apply SQL to the problem, and it will solve in a minute.
“Moving photos around behind f-spot’s back” has been really helpful for the first steps, but he used copy-pasting. I simply did
UPDATE photos SET directory_path = (SELECT ‘/home/tomcat/Media’ || SUBSTR(directory_path,13,100) FROM photos AS a WHERE a.name = photos.name);
. This updates all the photo paths by reading the path from the 13th position (and for 100 characters, more than enough for my path names) and adding “/home/tomcat/Media” in front.
Easy!
No really, this should be made much easier. What’s the point in a new import location if you already got all your photos somewhere else?
If you read this and need help with a specialized query (read: path name), don’t hesitate to ask. Everybody who knows some SQL should be able to help you, though.

