Page 1 of 1

Error when running windows bat file.

Posted: 2017-02-16T13:47:03-07:00
by cerdmier
The command runs fine used directly through the command prompt. When I run it through the bat file it shows this error: MIssingArgument '-format' at CLI arg 3 @fatal/magick-cli.c/ProcessCommandOptions/444

The main goal is to write the pixel counts of black and white to the txt file.

Thanks for any help that can be given.

Here is my bat I am running.
---------------------------
REM ask user for Filename
set /p filename= Enter File Name:
echo The File name is - %filename%.
pause
REM Create Folder
md C:\Users\Public\Pictures\%filename%
ren C:\Users\Public\Pictures\img.bmp %filename%.bmp
move /-Y C:\Users\Public\Pictures\%filename%.bmp C:\Users\Public\Pictures\%filename%\%filename%.bmp
echo Folder created..
echo Processing Image...
REM process Image and place in new folder
magick.exe C:\Users\Public\Pictures\%filename%\%filename%.bmp -monochrome -format %c histogram:info:C:\Users\Public\Pictures\%filename%\%filename%.txt
pause
------------------------

Re: Error when running windows bat file.

Posted: 2017-02-16T14:18:46-07:00
by fmw42
I am not a Windows user, but I believe all % need to be doubled as %% in .bat files. See http://www.imagemagick.org/Usage/windows/ or Windows syntax issues.

Re: Error when running windows bat file.

Posted: 2017-02-16T15:25:42-07:00
by GeeMack
cerdmier wrote: 2017-02-16T13:47:03-07:00 The command runs fine used directly through the command prompt. When I run it through the bat file it shows this error: MIssingArgument '-format' at CLI arg 3 @fatal/magick-cli.c/ProcessCommandOptions/444

magick.exe C:\Users\Public\Pictures\%filename%\%filename%.bmp -monochrome -format %c histogram:info:C:\Users\Public\Pictures\%filename%\%filename%.txt
As fmw42 mentioned, the percent signs "%"in a BAT script — other than the ones at each end of the SET variables — need to be doubled "%%".

Re: Error when running windows bat file.

Posted: 2017-02-17T05:35:31-07:00
by cerdmier
That got it! The %c switch for format needed to be %%c. Everything else using the filename variable was working as it should. Thanks for your help.