Refresh darktable database

I finally managed ( with the help of @kmilos ) to configure darktable so that it correctly recognized (works as designed) my Sigma lens mounted on a Canon body.

For anyone looking for lens recognition through darktable, this link may help: Exiv2 - Image metadata library and tools

For this change to be applied to all files already imported, it is necessary to “refresh the metadata”.

Deleting the collection and reimporting the files does this, but doing it one by one is not viable.

I looked for information about this in the darktable manual, on GitHub and in this forum without success.
I even looked in the /darktable/tools directory in git in an attempt to find something.

Can anyone guide me how to do this?

Select all images in lighttable, then Lighttable → Actions on selection → Metadata tab → Refresh exif. But be careful (from manual ) :

Warning: this may overwrite some tags and metadata that you have altered in darktable (such as star ratings).

2 Likes

There might be a couple of ways…one way might be to run DT with the command line option --configdir “path” and point it to a new folder, ie “path” DT will create a new clean database and then if you have xmp files for all your images you could just import them all… You could see how that looks and if successful you could port that over to become your main database rather than an alternate database…

I think that would be safe but maybe there is a more elegant way to simply “refresh” it…

I know you can also use SQL and edit things (on a backup of course)

1 Like

Thank you very much. I was looking for something like this in the collection panel. Thinking about something that could be applied directly to the collection. In my searches I looked for “refresh metadata” and “refresh database”, but not “refresh exif”.

If I had a little more time to study the darktable database, I would choose to try the SQL solution. As my collections are a mess, forcing the creation of a new database seems like a more appropriate option at this moment. Thank you very much for showing me the way.

Shouldn’t be too difficult. In library.db you have table

images
...
model_id : INTEGER
lens_id : INTEGER
...

These IDs refer to the tables, which you can use to find the relation of ID and the name string

models
id : INTEGER
name : VARCHAR

and

lens
id : INTEGER
name : VARCHAR

Two simple examples : you can find all images where you used the lens of interest

select * from images where lens_id = ( select id from lens where name = 'old name of your lens' )

and you can replace the name in lens.name by

update lens set name = 'new lens name' where name = 'old name of your lens';

If your are working with your database file(s) always use a duplicate !!!

I kept the old bank and forced the creation of a new one.
When I logged into SW and checked what needs to be reconfigured, I realized that perhaps the work of editing the database, for me who have some knowledge of SQL, would be less laborious.
Your guidance and examples gave me the push I needed in this regard. Tonight, I’ll give it a try and let’s see what happens. Thanks again.

The filtering functionality of the collections module is also very powerful ( darktable 4.9 user manual - collections ). You can filter by many attributes and combine multiple filters ( AND / OR / EXCEPT ) to find and select the images you want.
But to modify (meta)data not reachable by the lighttable → metadata editor it might be the fastest way to directly manipulate the database using SQL.