Windows mogrify via batch

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
ksmith

Windows mogrify via batch

Post by ksmith »

I have this quick and dirty batch file:

Code: Select all

:: Picshrink.bat
rem @echo off

:main

pushd C:\Documents and Settings\ksmith\Desktop\pics
for /R %%U in (*.jpg) do mogrify -resize 1024x768 %%U
popd
goto :eof

:: DONE
My output is a lot of:

Code: Select all

C:\Documents and Settings\ksmith\Desktop\pics>mogrify -resize 1024x768 C:\Docume
nts and Settings\ksmith\Desktop\pics\S5008330.jpg
mogrify: unable to open image `C:\Documents': No such file or directory.
mogrify: unable to open image `and': No such file or directory.
mogrify: unable to open image `Settings\ksmith\Desktop\pics\S5008330.jpg': No su
ch file or directory.
Any ideas what I'm doing wrong? Is mogrify unable to handle spaces in a path?

Thanks,
Kevin
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Windows mogrify via batch

Post by magick »

Put quotes around your filename.
ksmith

Re: Windows mogrify via batch

Post by ksmith »

Geez, how did I miss that?

for /R %%U in (*.jpg) do mogrify -resize 1024x768 "%%U"
did the trick.

Thanks.
Post Reply