f-spot issues
July 20, 2011 | 6:59 pmLong time no see… Sorry.
Two days ago I’ve imported all photos found on different medias into f-spot. Unfortunatelly, there were lots of files to delete, because, basically, I didn’t know WHAT am I importing (photos? icons from different kind of software? JPEG-ed diagrams??).
There was lot of deleting, but it seems that files were removed from f-spot database, not from disk (what was my intention).
Now facts: There are 20217 and only 1342 entries in photos.db (just for reference, its location is ~/.config/f-spot). Have to find some way to delete this stuff…
I’ve found a script which does the opposite thing.
I’m very weak in bash and/or Perl, so I wrote this tiny script in Python:
import os
import sqlite3
ROOT = u'/media/TREKSTOR/zdjecia'
DB = u'/home/miszka/.config/f-spot/photos.db'
WHITELIST = set((u'photos.db', u'cleanup.py'))
conn = sqlite3.connect(DB)
c= conn.cursor()
for top, dirs, files in os.walk(ROOT):
for nm in (set(files) - WHITELIST):
c.execute(u"select id from photos where base_uri||filename=?",\
(u'file://'+os.path.join(top, nm),) )
if c.fetchone() is None:
print os.path.join(top, nm)
os.remove(os.path.join(top, nm))
It doesn’t remove empty directories, but you can do it on your own with find -type d -empty -delete
Well, it isn’t beautifull, I’m sure you can do everything in much less lines, but it workded for me.
Finally: you’re using it on your own responsibility.









