I try to write a .bat file with the following command-line

C:\Programme\ImageMagick-7.0.7-Q16\magick mogrify -path C:\temp\size -resize 21.15% -compress LZW *.tif

I create it the following way:

  • Open MS Editor
  • insert the text
  • save as xy.bat

When I run the xy.bat the “%” from "21.15%" is gone. What went wrong?

  • 1
    Why is the command in your image different from the command in the text of your question? – AFH Nov 7 '17 at 23:03
  • 1
    Try doubling the percent sign. This is a special character in batch files. It’ll work if you specify ‘21.15%%’. (Quotes then not needed). For example, %1, %2, %3, ... refer to command line parameters. %0 refers to the batch file. Then you have environment variables which are referred to as %varName%, %otherVarName%, etc. – BillP3rd Nov 8 '17 at 6:43
  • It works. The funny thing is, that it also works when I copy the command-line into the ms prompt. – UliW Nov 8 '17 at 7:06

It's difficult to see what is going wrong as your example and command line don't match, however, try putting single quotes around the parameter value:

C:\Programme\ImageMagick-7.0.7-Q16\magick mogrify -path C:\temp\size -resize '21.15%' -compress LZW *.tif

Examples from the Image Magick website on command line image geometry arguments: https://www.imagemagick.org/script/command-line-processing.php#geometry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.