I'm looking to build a small batch script that executes the command line of pngout.exe

So far I've got only this down

for %i in (*.png) do "g:\myfiles\_pngout.exe" "%i" /s0 /c6

However, for that to work I have to manually go to each folder where the pngs are and open up a cmd window from Win7 then copy and paste that line.

What I want is for that line to work say in C:\MyPNGs and it's sub-folders, like C:\MyPNGs\Avatars etc., it should iterate through all pngs and every time execute that "g:\myfiles\_pngout.exe" "%i" /s0 /c6

Any ideas?

  • Would you be opposed to using VBScript? I'm not that experienced with batch scripts, but I could write you something that does this in VBScript in 10 minutes.
    – rory.ap
    Apr 5, 2014 at 21:55
  • Nah, VBScript is fine too. I would just need to read up how to run it. Should be easy doable. Apr 5, 2014 at 22:18

1 Answer 1


You can use the following command from a dosprompt:

for /r %f in (*.png) do _pngout.exe "%f"

or the following inside a batch file:

for /r %%f in (*.png) do _pngout.exe "%%f"

For /r also has support to give a start directory. Otherwise it'll use the current directory and get every file in all subdirectories that match your filemask.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.