Bug #12096

darktable.control.execute - quotes issue under windows

Added by Philippe Weyland about 2 years ago. Updated over 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected Version:
hardware architecture:


When the executable is in a folder like "C:\Program files (file86)\ExifTool.exe", double quotes are necessary.
That works until no other double quotes are needed for other file reference or parameters.
As soon there is some other double quotes, that doesn't work any more for the executable.
This command works:

LUA "C:\Program Files (x86)\Exiftool\exiftool.exe" -@ C:\Documents\Darktable\lua\dt-plugins\ExifWeb.txt D:\Documents\Images\Photos\2010\2018\20180310_Ipoema\DTw\20180310_Ipoema_002.jpg

This command doesn't work:

LUA "C:\Program Files (x86)\Exiftool\exiftool.exe" -sep ", " -XMP:HierarchicalSubject="Brasil|Minas Gerais|Ipoema" :\Documents\Images\Photos\2010\2018\20180310_Ipoema\DTw\20180310_Ipoema_002.jpg
'C:\Program' is not recognized as an internal or external command,

I can make it work putting ExifTool.exe in folder without space and removing the double quotes on executable:

LUA C:\ET\exiftool.exe -@ C:\Documents\Darktable\lua\dt-plugins\ExifWeb.txt -sep ", " -XMP:HierarchicalSubject="Brasil|Minas Gerais|Ipoema" D:\Documents\Images\Photos\2010\2018\20180310_Ipoema\DTw\20180310_Ipoema_002.jpg

If I let the double quotes I get another error:

LUA "C:\ET\exiftool.exe" -@ C:\Documents\Darktable\lua\dt-plugins\ExifWeb.txt -sep ", " -XMP:HierarchicalSubject="Brasil|Minas Gerais|Ipoema" D:\Documents\Images\Photos\2010\2018\20180310_Ipoema\DTw\20180310_Ipoema_002.jpg
The filename, directory name, or volume label syntax is incorrect.

exiftool_export_windows.lua (4.25 KB) exiftool_export_windows.lua exiftool modul for windows example Christian Kanzian, 03/27/2018 05:13 PM


#1 Updated by Christian Kanzian about 2 years ago

You need to escape the quotes with \ so that they are not interpreted by LUA itself.

You can build the command by concatenate strings with .. in LUA like this

exif_cmd = "exiftool ".."\""..tostring(cmd_options.value).."\"".." -overwrite_original ".."\"" .. imgexp .. "\""

I attach the example from the discussion above, which should add a new modul below the export module in lighttable mode.
If the exiftool is not in your Windows PATH you need to replace "exiftool " with your "C:\Program Files (x86)\Exiftool\exiftool.exe" in line 113 and 117.

#2 Updated by Philippe Weyland about 2 years ago

Hi Christian
I've tried also what you suggest.
Without extra quote and an executable name without space that works (exactly as in your example).
But with "C:\Program Files (x86)\Exiftool\exiftool.exe" I do not succeed.
The widget giving the filename provides already the quotes. If I remove them and add them again that doesn't change anything (seems normal to me).
Can you make your plugin work with something like "C:\Program Files (x86)\Exiftool\exiftool.exe" ?

(By the way I like your example, far smarter than the one I did. I'll work on it. Mine is there: : fileondiskExif)
Thank you for your comments.

#3 Updated by Philippe Weyland about 2 years ago

The thread confirms the findings here above.

[]to pass execute commands with spaces the binary location needs to be quoted “path with spaces/to/bin.exe” and then any arguments that follow CANNOT have quotes.>

#4 Updated by Bill Ferguson over 1 year ago

The only way I've found to get a quoted command with quoted arguments to run on windows is by building a batch file with the command, then using dt.control.execute to run the batch file. I wrote a function external_command() which wraps dt.control.execute. If the command is running on windows, then another function is called windows_command(), which builds the batch file and executes it. These functions are in lib/dtutils/system.lua and you would use it as follows:

local dtsys = require "lib/dtutils.system"

local result = dtsys.external_command(<your command here>)

If you're running on linux or MacOS, then external_command() just passes the command to dt.control.execute().

It may not be a fix, but it's a workaround that works.

Also available in: Atom PDF

Go to top