Page 1 of 1

recursive transparency (windows commandline)

Posted: 2014-07-11T04:04:42-07:00
by RAB74
Dear list,

I am a brand new ImageMagick user (working in Windows 7) so forgive my ignorance but I would like to recurse this command to convert the background of a png to transparent, overwriting the original files (rather than copying to a new folder)

Code: Select all

FOR %G IN (*.png) DO convert %G -transparent white test \%G
By following the thread here viewtopic.php?f=1&t=14112&start=15 and example here
I put together this command

Code: Select all

FOR /R %%a IN (*.png) DO convert -transparent white "%%~a" "%%~dpna.png
getting this error

Code: Select all

%%a was unexpected at this time.
Altering to:

Code: Select all

for /R %i IN (*.png) DO convert -transparent white "%i" "%%~dpna.png"
(based on another batch script I have) runs but does not overwrite the output to the original files instead to a png named %~dpna in the top folder
If anyone has a moment to help me tweak the code I would really appreciate the advice!

Thanks for reading
Rebecca

Re: recursive transparency (windows commandline)

Posted: 2014-07-11T05:34:30-07:00
by snibgo
If you are typing at the command line, don't double percent characters.

If you are running BAT files, do double percent characters.

Your last command sets up variable %i but uses both %i and %a.