On 17 August 2013 14:55, Markus Jung <[email protected]> wrote: > Am 17.08.2013 06:06, schrieb Daniel J Blueman: >> After I finish exporting pictures in darktable, I have a script which >> archives the pictures, moving out the raw files, leaving a bunch of >> missing file markers (skull image) in Darktable. >> >> Is there a way to prune the image database of removed pictures, eg >> 'darktable-cli prune' or in the GUI? I guess I could use sqlite if >> nothing else, or delete the database file...
> GIT contains "purge_non_existing_images.sh" in "tools". Superb tip! As I'll integrate this into another script, I cooked it into efficient python [1]. Can this be added to the darktable repo? It serves as a good template for fast and safer database manipulation, as the select and delete statements are executed holding the same table lock and if any error, the transaction is rolled back (due to the neat 'with' clause semantics). Thanks, Daniel --- [1] http://quora.org/2013/prune.py #!/usr/bin/python import os, sqlite3 db = sqlite3.connect(os.environ['HOME'] + '/.config/darktable/library.db') with db: query = 'select A.id,B.folder,A.filename from images as A join film_rolls as B on A.film_id = B.id' for seq, folder, filename in db.execute(query): path = '%s/%s' % (folder, filename) if not os.path.exists(path): print 'removing stale reference to %s' % path db.execute('delete from images where id=%d' % seq) ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ darktable-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/darktable-devel
