I want to convert all my PNGs to PNG using ImageMagick (I need this because AndroidStudio has some issue with the original PNGs. ImageMagick is able to fix this issue by re-exporting the PNG.)
If I do:
convert a.png a.png it works.
But how do I do this for many files (including files from sub directories)?
Best How To :
For Windows users -- you can try this in a
for %i in (*.png *\*.png *\*\*.png *\*\*\*.png) do (
convert.exe %i %~pni---repaired.png
This will loop through the current dir's PNGs as well as the ones in the sub directories 3 levels deep.
You have to make sure that your
convert.exe really is the one from ImageMagick -- set up your environment variable
%PATH% accordingly. Otherwise you may run into an error when the command wants to use the identically named disk format conversion
If unsure, use the full path to the IM
D:\programs\imagemagick-install-dir\convert.exe %i %~pni---repaired.png
Also, remember: If you put the above command into a
*.bat file, you have to double up each occurrence of
%i from the direct command becomes
%%i in the batch file!
If you are on Vista/Windows7/2008/8 (or on Windows XP with the Resource Kit installed) you'll have the
ForFiles.exe available, which can be used to loop through files:
/p <path> ^
/m *.png ^
/C "convert.exe @file @fname---repaired.png"