searching for files

DT 3.6.1. on opensuse leap 15.3.

I have a list of 739 images, 1 image per line.

I’d like to search for all of them in DT and assign some tag to do some further processing.

Do I have to do it one at a time? this will be very painful :frowning: :frowning: :frowning:

Is there some way to assign some flag or some tag from the command line?

Thank you

Are they all untagged in darktable? Are they from the same day or time? You can sort and filter for them in darktable.

You can also close darktable, use the list to modify the XMP file, then start darktable again and it should import the XMP file, if you have that config option checked.

These are “random” images. My wife, aka The Boss, has picked them. They span 10 years of photos. I will be making a blurb book as a present for her best friend.

That would work for me, if I could create an exiftool tag called: the-boss and write it in the xmp, then dt could be refreshed/re-read xmps, then I could do my processing.


Tags aren’t saved in the xmp file, they are saved in the database.

Not sure if you use Ratings with your images, if you don’t you can use that. Near the top of the xml file there’s an entry that looks like this:


Change that to, say, 5 stars:


Now you can limit what’s shown to 5 stars and you are good to go with the selective tagging.

You still need to stop darktable firtst before doing this and have the correct config option checked to let darktable pick up on the xml changes afterwards.

Just in case and assuming your list consists of name.raw_extension (foo.nef or /full/path/to/bar.CR2), this one-liner might come in handy:

while read THIS; do sed -i 's/xmp:Rating="0"/xmp:Rating="5"/' "${THIS}.xmp"; done <image.list.txt

cant’ get the above to show as one line, but it is supposed to be…

Do make sure you test this first, though!


As mentioned by elstoc and pehar below it turns out that tags ARE saved in the xmp!

Not sure what would be easier for you to do, though: Creating a script that adds a correct block of xml to each xmp or approach this via the above workaround. The latter would change just one field and the bulk tagging is done from within darktable.

Tags are saved to the xmp file (or they should be). The xmp should allow all changes to the file to be reconstructed, and so should contain the same information (about the image and its edits) as is stored in library.db.

I added a tag “atest” to an image and saw the following in my xmp:


They are :




And more importantly for what @foto wants, tags are read from XMP files.

The trick with an external script is figuring out which XMP fields to populate. Perhaps he can compare with what digikam writes to its sidecars (which are read by dt).

@elstoc @pehar

I stand double corrected…

I really though that they are part of the data.db (tags table) and library.db (tagged_images table). Once I noticed that (way back) I never bothered to look in the xmps. My bad!

Well, at least I offered a one-liner that can be used :sweat_smile:

  1. Thanks for the ideas
  2. Here’s how I’ve done it in bash/linux, if somebody else is interested:
sed -i 's/<rdf:Bag>/<rdf:Bag>\n     <rdf:li>special|the-boss<\/rdf:li>/' file001.xmp

This changed both, the keywords and the hierarchical keywords.

I’m not sure how long it took to run on the 739 files, I launched and went to walk (in the downpour) with my dog…