I have the following batch script in a button in dopus. For some reason it seems it won't work if I select a video file and click on the button. However if I make a *.bat file with the excat same content (except @externalonly) I am able to run the batch script. Why is this? How can I make the batch script run from inside a button?
<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none">
<label>Extract part of a video to a new file</label>
<tip>Extract part of a video to a new file</tip>
<function type="batch">
<instruction>@externalonly</instruction>
<instruction />
<instruction>@echo off</instruction>
<instruction />
<instruction>rem CREDITS: http://stackoverflow.com/questions/8547676/droplet-batch-script-filenames-containing-ampersands</instruction>
<instruction>rem Explanation: echo off is needed to use rem</instruction>
<instruction />
<instruction>set /p startposition=Enter the start position (e.g 00:01:35):</instruction>
<instruction>set /p endposition=Enter the end position (e.g 00:50:38):</instruction>
<instruction>rem Explanation: Here we set the timing for where we want to cut the input</instruction>
<instruction />
<instruction>setlocal disableDelayedExpansion</instruction>
<instruction>rem Explanation: Expand variables at parse time rather than at execution time.</instruction>
<instruction />
<instruction>rem THE FOLLOWING ENABLES DRAG-AND-DROP FOR THE BATCH SCRIPT</instruction>
<instruction>rem ---------------------------------------------------------------------------------------</instruction>
<instruction>:: first assume normal call, get args from %*</instruction>
<instruction>set args=%*</instruction>
<instruction>set "dragDrop="</instruction>
<instruction>::</instruction>
<instruction>:: Now check if drag&drop situation by looking for %0 in !cmdcmdline!</instruction>
<instruction>:: if found then set drag&drop flag and get args from !cmdcmdline!</instruction>
<instruction>setlocal enableDelayedExpansion</instruction>
<instruction>set "cmd=!cmdcmdline!"</instruction>
<instruction>set "cmd2=!cmd:*%~f0=!"</instruction>
<instruction>if "!cmd2!" neq "!cmd!" (</instruction>
<instruction> set dragDrop=1</instruction>
<instruction> set "args=!cmd2:~0,-1! "</instruction>
<instruction> set "args=!args:* =!"</instruction>
<instruction>)</instruction>
<instruction>::</instruction>
<instruction>:: Process the first argument only</instruction>
<instruction>for %%F in (!args!) do (</instruction>
<instruction>if "!!"=="" endlocal & set "dragDrop=%dragDrop%"</instruction>
<instruction>rem ------------------------------------------------</instruction>
<instruction>rem - Your file processing starts here.</instruction>
<instruction>rem - Use %%F wherever you would normally use %1</instruction>
<instruction>rem</instruction>
<instruction>rem Change to drive and directory of input file</instruction>
<instruction>%%~dF</instruction>
<instruction>cd %%~pF</instruction>
<instruction>rem ffmpeg: mix to one channel, double the volume</instruction>
<instruction>rem ffmpeg.exe -i "%%~nxF" -ac 1 -vol 1024 "%%~nF new%%~xF"</instruction>
<instruction>rem ---------------------------------------------------------------------------------------</instruction>
<instruction />
<instruction>rem PUT YOUR FFMPEG INSTRUCTIONS HERE</instruction>
<instruction>ffmpeg -i "%%~nxF" -c copy -ss %startposition% -to %endposition% "edited-%%~nF%%~xF"</instruction>
<instruction />
<instruction>rem ---------------------------------------------------------------------------------------</instruction>
<instruction>rem</instruction>
<instruction>rem - Your file processing ends here</instruction>
<instruction>rem -------------------------------------------------</instruction>
<instruction>goto :continue</instruction>
<instruction>)</instruction>
<instruction>:continue</instruction>
<instruction>if defined dragDrop (</instruction>
<instruction>pause</instruction>
<instruction>rem exit</instruction>
<instruction>)</instruction>
</function>
</button>
Please note that I already know how to run an external file but I would like to keep the batch script inside a button.