Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – roryap Apr 5 '14 at 21:55
Nah, VBScript is fine too. I would just need to read up how to run it. Should be easy doable. – Grumpy ol' bear Apr 5 '14 at 22:18
up vote 3 down vote accepted

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.

share|improve this answer
Cheers! That did it! – Grumpy ol' bear Apr 6 '14 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .