Darktable Lua script. Help needed

Hello guys,
I use darktable to edit my raw captured images in bulk.

basically my workflow in darktable goes like this
1-import raw images from folder A.
2-edit all the images at once using pre-defined style.
3.export images as jpg to folder B.

And to increase my productivity I looked to use Lua script to automate my workflow.
but I ran against the wall trying to import the images :frowning:

though I got “Hello World!” showing up in darktable :slight_smile:

=========Here is the code========
dt = require “darktable”

I havn’t tested anything, everything I’m writing here is wild guessing. Perhaps @wpfergusoncan test it on his Windows machine.

What doesn’t work?
Have you created a new file and then require this file in the luarc? Like this:

require "test.lua"

First of all you should make dt local to not get into conflicts with other scripts.

local dt = require “darktable”

I think you need to escape the “” like this:


Is a new film created with the name “D:\imgee”? (It is interesting, that we have no script in the git repository, that uses “films.new”. So this is not the best tested function.)

And here again I think you need to escape the “” like this:


To check error messages you can run dt from the command line like this:

C:\Program Files\darktable\bin>darktable.exe -d lua

The logs are then here written:

I am running it inside the luarc file and It’s partially working
it does create xmp files in side the directory but it is not showing up the images in darktable

So I know this part at least is working


but it’s not showing up in darktable, because (if I am not mistaken) images must be added to film

and I think that’s because of I am not doing this command right



Tobias thank you for replying I really appreciate it

In order to display them I believe that you are going to have to do a


I’ve not used this, so I don’t have any examples of exactly how to do it.

You could check to see if your import was successful by using the collect module and selecting the film you created.

The only time that dt.database.import() displays the images is when you import into the current film role, AFAIK.

Hope this helps,


Thank you Bill,
I can see the problem now more clearly

Yes I just noticed that, and the same as well with any of film rolls under “recently used collections” in GUI .

Now I know that I am not getting “dt.films.new()” correctly…

So any idea what command that I can use to create a film roll for a directory properly?

Thank you again

I think this will work…

local new_film = darktable.database.import(path to directory)


P.S. I’m going to close the issue in github.com/darktable-org/lua-scripts, since this is the better venue to work this problem.

And to display it…

local rule = darktable.gui.lib.collect.new_rule()
rule.data = tostring(new_film) 


1 Like