Error when running windows bat file.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
cerdmier
Posts: 2
Joined: 2017-02-16T13:40:00-07:00
Authentication code: 1151

Error when running windows bat file.

Post 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
------------------------
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error when running windows bat file.

Post 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.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Error when running windows bat file.

Post 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 "%%".
cerdmier
Posts: 2
Joined: 2017-02-16T13:40:00-07:00
Authentication code: 1151

Re: Error when running windows bat file.

Post 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.
Post Reply