luasdklightroom

Lua execute windows command in Lightroom SDK


I’m porting my lightroom plugin to Windows. On MacOSX everything works perfect.

Now i’m stuck with one command, Normally I try to use as mutch of LR commands because they are compatible with both OS’s.

cmdRunExifTool = string.format('cd "'..NewTargetDir..'"  &&  '.._PLUGIN.path..'\\bin\\win\\exiftool.exe '..(optionOverwrite or "")..' optionAppend=".\\C+F-'..NewJson..'" .') 
LrTasks.execute(cmdRunExifTool)

I have added a pop-up window with the command and it show me this:

cd "c:\Users\patri\Pictures\TEST-IMAGES\FF690-KTMX-000869\_scans\positives\C+F_exiftool" && c:\Users\patri\Documents\AnalogeFotografie.lrplugin\bin\win\exiftool.exe optionAppend=".\C+F-mybeelden" .

But nothing happens. If I run this on the command line it works !


Solution

  • For WIN_ENV you have to surround the whole cmdline with double-quotes (")

    function cmdlineQuote()
        if WIN_ENV then
            return '"'
        elseif MAC_ENV then
            return ''
        else
            return ''
        end
    end
    
    cmdRunExifTool = 
        cmdlineQuote() .. 
        string.format('cd "'..NewTargetDir..'"  &&  '.._PLUGIN.path..'\\bin\\win\\exiftool.exe '..(optionOverwrite or "")..' optionAppend=".\\C+F-'..NewJson..'" .')  ..
        cmdlineQuote()
    LrTasks.execute(cmdRunExifTool)