Mogrify -resize works in cmd.exe but not in .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
visitor x
Posts: 16
Joined: 2013-07-27T13:26:38-07:00
Authentication code: 6789

Mogrify -resize works in cmd.exe but not in .bat file

Post by visitor x »

If i do it manually with cmd.exe mogrify works a charm.

However, when I run it from a .bat file it fails. I tried some with convert too just in case but no joy. The error code is always The command "mogrify" is missing or not found.

I thought I had found the answer here but as my images are being created and the active directory is where I want it I don't see how that could be the issue.

I have opened a console, cd to the new directory created by the above, copied and pasted one of the below mogrify commands and it works fine.

So I reckon it's either down to a difference between cmd and bat that I'm not aware of or something in imagemagick. Either way I'm new to both so hoping someone can help me.

Code is as follows:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
md "%path%"
cd %path%

copy %1 "ios_144x144.png"
copy %1 "android_ldpi.png"
copy %1 "android_mdpi.png"
copy %1 "android_hdpi.png"
copy %1 "android_xhdpi.png"
copy %1 "ios_57x57.png"
copy %1 "ios_72x72.png"
copy %1 "ios_114x114.png"
copy %1 "ios_144x144.png"

pause //Check here to see if dir and images created and that command line is now in %path%. In test runs all is okay as far as here

convert -resize 36x36 android_ldpi.png
mogrify -resize 48x48 android_mdpi.png
mogrify -resize 72x72 android_hdpi.png
mogrify -resize 96x96 android_xhdpi.png
mogrify -resize 114x114 ios_114x114.png
mogrify -resize 144x144 ios_144x144.png
mogrify -resize 72x72 ios_72x72.png
mogrify -resize 57x57 ios_57x57.png


echo Verzeichnis %path% fertig.

pause>nul
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify -resize works in cmd.exe but not in .bat file

Post by snibgo »

What version of Windows are you running? What version of IM?

At the command prompt, type

Code: Select all

where mogrify.exe
What is the result?

Also put that line in the bat file. What is the result?
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify -resize works in cmd.exe but not in .bat file

Post by snibgo »

EDIT: the problem is:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
This wipes out your path! Windows will no longer be able to find programs in their usual places.

Call it something different, eg "mypath".
snibgo's IM pages: im.snibgo.com
visitor x
Posts: 16
Joined: 2013-07-27T13:26:38-07:00
Authentication code: 6789

Re: Mogrify -resize works in cmd.exe but not in .bat file

Post by visitor x »

snibgo wrote:What version of Windows are you running? What version of IM?

Windows 7, ImageMagick-6.8.8-Q16

At the command prompt, type

Code: Select all

where mogrify.exe
What is the result?

C:\Program Files\ImageMagick-6.8.8-Q16\mogrify.exe is the result. My env var is also set to here

Also put that line in the bat file. What is the result?
C:\Program Files\ImageMagick-6.8.8-Q16\mogrify.exe
visitor x
Posts: 16
Joined: 2013-07-27T13:26:38-07:00
Authentication code: 6789

Re: Mogrify -resize works in cmd.exe but not in .bat file

Post by visitor x »

snibgo wrote:EDIT: the problem is:

Code: Select all

set path=icons %date:~0% %time:~0,2%_%time:~3,2%_%time:~6,2%\
This wipes out your path! Windows will no longer be able to find programs in their usual places.

Call it something different, eg "mypath".
Thank you!!!!!! Egg and my face, same trajectory!
Post Reply