Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why I am getting The following usage of the path operator in batch-parameter substitution is invalid

I have a batch file which should get a directory and process all jpeg files in it using an application that i have.

The batch file is:

for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%~dpI\output\%~nxI"
)

but when I am running this batch file, I am getting this error:

The following usage of the path operator in batch-parameter substitution is invalid: %~dpI\output\%~nxI"

I read the format specifier and it says:

%~dpI       - expands %I to a drive letter and path only
%~nxI       - expands %I to a file name and extension only

based on it, the syntax should be correct?

What is the problem?

like image 707
mans Avatar asked May 05 '15 09:05

mans


1 Answers

Inside a batch file, you need two % symbols when you're using the for loop variables. Variables like %I would only be for the command line. You should be saying

for %%I in (%1\*.jpg) do (
    bin\process.exe %%I "%%~dpI\output\%%~nxI"
)
like image 179
SomethingDark Avatar answered Oct 11 '22 02:10

SomethingDark