filter using image id

I like the idea of using the image id in the exported file name.
I would like to identify the image back in the database using only the image id field. Unfortunately it is not possible (or I didn’t find out) to filter images in lighttable using the image id attribute. I tried the search collection filter, but it doesn’t work.
Is there any other possibility? Maybe using lua scripting? :slight_smile:

sqlite3:

$ sqlite3 library.db "select folder, filename from images i join film_rolls r on i.film_id = r.id where i.id=18205"
/home/kofa/Pictures/import/2025-10-18|2025-10-18-16-20-29-DSC_0531.NEF
2 Likes

I wrote a LUA script some weeks ago to select (not filter) images with an SQL command. It’s tested on linux only at the moment. sqlite3 needs to be installed on your system to run this script.

sql-database-query.lua.txt (13.1 KB)

It can be risky to execute SQL commands on the database (directly from darktable). Be sure to read the warnings in the comment lines of the script.

Any use of this script is at your own risk !

2 Likes

Thanks, sql query is a very good start point! I’ll need to figure out only the filtering.

1 Like

This is possible with the script in its current state, both with and without selecting the images found. Example :

If you need the full path instead of the file name, you can extend line 229 of the script

result = result .. value .. " : " .. img.filename .. "\n"

by adding img.path.

1 Like

@pehar thanks, I got it, it’s working now! :slight_smile: