Project

General

Profile

Bug #12096

darktable.control.execute - quotes issue under windows

Added by Philippe Weyland about 1 year ago. Updated 9 months ago.

Status:
New
Priority:
Low
Category:
Lua
Target version:
-
Start date:
03/26/2018
Due date:
% Done:

0%

Affected Version:
2.4.1
System:
Windows
bitness:
64-bit
hardware architecture:
amd64/x86

Description

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 - exiftool modul for windows example (4.25 KB) Christian Kanzian, 03/27/2018 05:13 PM

History

#1 Updated by Christian Kanzian about 1 year 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 .. "\"" 

https://discuss.pixls.us/t/name-description-and-keywords-are-not-recognized-by-shutterstock/6726/27?u=pk5dark

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 1 year 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: https://github.com/phweyland/dt-plugins : fileondiskExif)
Thank you for your comments.

#3 Updated by Philippe Weyland about 1 year ago

The thread https://discuss.pixls.us/t/enfuse-pro-plugin-cross-platform-compatible/7094/4 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 9 months 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