I've been removing unwanted images from Darktable by pressing the Del key. I just learned that this isn't deleting the images from my hard drive, only removing them from the Darktable database.

How can I delete (from my hard drive) the images that I've already removed from Darktable?


5 Answers 5


Darktable has two distinct operations: Remove and Delete/Trash. By default, the DEL key is bound to the former. That just removes the information about that file from the database, and doesn't affect the actual file. You can change this in the preferences under shortcuts:

darktable preferences dialog

Double-click on the "delete from disk or send to trash" line and then press DEL. Now, in the future, deletion will be "real" on the filesystem, not just in the database.

Unfortunately for you, there's no way to do this retroactively, because by definition now darktable doesn't know about those files.

Darktable includes a script to do the opposite: remove files from the database when they don't exist on disk anymore. If you have a little bit of shell script and SQL knowledge, that example should get you started on doing the reverse.

Or you could use @junkyardsparkle's clever suggestion.

  • 3
    \$\begingroup\$ I personally leave Delete bound to "remove from collection", and use Shift + Delete for "delete from disk"... since both are useful. \$\endgroup\$ Jun 8, 2018 at 22:03

You can give 5 stars to all images in you collection (select all, then press key 5), and then use the following script to delete all images that have a ranking of 1 (default ranking).

for f in `grep -l 'Rating="1"' \`ls *.xmp\``
    rm ${f%.xmp}
    rm $f

This assumes you have not changed the rating of the images you have removed. Alternatively, if you have "rejected" the images before removing them, replace 'Rating="1"' by 'Rating="-1"'

If you want to make sure this is not going to remove unintended files, you can always add echo before rm, which will write which files will be deleted without deleting them.


If you really want to do this from within darktable, you could try doing something like adding a very unique tag to all of the images currently in darktable's database, then doing a recursive (re)import of images from the root directory of your image collection, then use darktable's collection features to collect all images without that tag, and then actually delete them after carefully looking them over to be sure you've collected what you intended to. Then remove the marker tag from the rest of the files in the database.

This is purely theoretical, I've never tried it, and the process might be painful on a large collection. It also assumes that you're talking about RAW files, so that any previously exported JPEGs can be excluded from the re-import step. If you try it, make absolutely sure that what you're about to delete is what you actually want to delete.


As far as I know, that's not possible from within darktable in any direct way.

If you have marked all the removed images before removing them, reloading the folders might show the removed images with the marks intact, so you can select them and then "delete" the selected images. On removal, Darktable leaves the xmp files alone, and those contain any markup you did on the images prior to removal.

Otherwise, you might have to use the Darktable database, and remove all files that are not present in the database. That probably needs a script, which might or might not already exist. If you don't get a better answer here, you could ask on the Darktable mailing list
([email protected]).


With a little help from the terminal or file-manager:

  • select all pictures in lighttable
  • create a temp_dt directory
  • selected images -> move > select temp_dt
  • remove all files in original directory with file-manager / terminal
  • move all files back to original directory
  • delete temp_dt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.