2

I have a folder structure with one main parent folder containing many subfolders, and in these some PNGs, something like:

.../data

.../data/013523/
.../data/345343/
.../data/395338/

.../data/013523/filex.png
.../data/013523/filey.png
.../data/345343/filea.png
.../data/345343/fileb.png
.../data/345343/filec.png

I'd like to crush all these PNGs with a Windows batch-script knowing only the location of the parent data folder (ie the folder names and png names are unknown, it should just crush all PNGs in all folders).

I took a look at Drag and drop batch file for multiple files? but this didn't seem to be quite what I was after.

Oh and no fancy naming options required, crushing in-place is fine.

Community
  • 1
  • 1
Joseph Earl
  • 23,351
  • 11
  • 76
  • 89

1 Answers1

5

Well

for /r ...\data %%x in (*.png) do pngcrush "%%x"

should do it.

If the path to your data directory contains spaces somewhere, the following should work better, though:

pushd "...\data"
for /r %%x in (*.png) do pngcrush "%%x"
popd
Joey
  • 344,408
  • 85
  • 689
  • 683