ARGH!! Command works but not in batch 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
Misty1
Posts: 3
Joined: 2013-09-06T07:27:11-07:00
Authentication code: 6789

ARGH!! Command works but not in batch file?!!

Post by Misty1 »

I'm running a basic convert command, which works perfectly when I type/copy it into DOS;

convert c:\Photo_Uploads\camera\*.jpg -resize 20% -set filename:fname '%t_tn' +adjoin z:\%[filename:fname].jpg

All it does is resize the jpg's and move them to another folder. If I use this command in a batch file, it fails with the following error;

convert.exe: invalid argument for option `-resize': 20fname @ error/convert.c/ConvertImageCommand/2451.

So it looks like it doesn't even call the whole command before failing. I can't figure it out and am at my wits end. If anyone can suggested anything I'd be in their debt!!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: ARGH!! Command works but not in batch file?!!

Post by Bonzo »

You need to escape the % in a batch file usualy with another %.

Check out this page

You probably need to change '%t_tn' to "%%t_tn" as Windows needs " and not '
Misty1
Posts: 3
Joined: 2013-09-06T07:27:11-07:00
Authentication code: 6789

Re: ARGH!! Command works but not in batch file?!!

Post by Misty1 »

Thanks for your help, though if I double the % signs;

convert c:\Photo_Uploads\camera\*.jpg -resize 20% -set filename:fname '%%t_tn' +adjoin z:\%%[filename:fname].jpg

although it takes longer to run, it fails with the same error message;

convert.exe: invalid argument for option `-resize': 20fname @ error/convert.c/ConvertImageCommand/2451.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: ARGH!! Command works but not in batch file?!!

Post by Bonzo »

What about the 20% :D
Misty1
Posts: 3
Joined: 2013-09-06T07:27:11-07:00
Authentication code: 6789

Re: ARGH!! Command works but not in batch file?!!

Post by Misty1 »

Heh, I feel like a right tool now!! That worked, thanks a million for your help :D
Post Reply