Search code examples
batch-fileimagemagickmogrify

Mogrify command works from CMD but not from .bat file


I execute the following command (turn all black color elements to pink in any image) with CMD and it works perfectly ( all the images are changed):

mogrify -path img/images img/images/*.* -fuzz 95% -fill pink -opaque black img/images/*.*

but when using the same command on .bat file, only some images are changed and other are changes to the wrong result (some images turn black with pink frame):

@echo off 
cd /d "C:\Program Files\ImageMagick-6.9.1-Q16"
mogrify -path img/images img/images/*.* -fuzz 10% -fill pink -opaque  black img/images/*.*

any ideas why?


Solution

  • You need to double up your percent signs when inside a batch file... see Anthony Thyssen's excellent ImageMagick examples and notes here.

    So, your -fuzz 10% will need to become -fuzz 10%% inside a batch file.