I'm trying to process a folder directory with pngquant that has a structure of :
C:\ ├───FOLDER │ ├───0 │ │ └───0 │ ├───1 │ │ └───0 │ └───2 │ ├───113 │ ├───114 │ ├───120 │ └───121
I'm using pngquant to lower the size of the PNG files that are under C:\folder\1\0\*.png
. I do *.png because each folder may contain more than 300 small PNG files, but I need to go through all the folders and replicate the exact folder structure at another location with the compressed PNGs.
In Windows I have a shell script that does
for d in $(find C:/$folder_name -maxdepth 2 -type d)
do
path/to/pngquant.exe --ext .png --force 2 $d/*.png
done
but this just overwrites all the files in the directory.
This is the help manual of pngquant.
pngquant, 2.0.0 (March 2013), by Greg Roelofs, Kornel Lesinski. Compiled with libpng 1.5.14; using libpng 1.5.14. usage: pngquant [options] [ncolors] [pngfile [pngfile ...]] options: --force overwrite existing output files (synonym: -f) --nofs disable Floyd-Steinberg dithering --ext new.png set custom suffix/extension for output filename --speed N speed/quality trade-off. 1=slow, 3=default, 11=fast & rough --quality min-max don't save below min, use less colors below max (0-100) --verbose print status messages (synonym: -v) --iebug increase opacity to work around Internet Explorer 6 bug --transbug transparent color will be placed at the end of the palette Quantizes one or more 32-bit RGBA PNGs to 8-bit (or smaller) RGBA-palette PNGs using Floyd-Steinberg diffusion dithering (unless disabled). The output filename is the same as the input name except that it ends in "-fs8.png", "-or8.png" or your custom extension (unless the input is stdin, in which case the quantized image will go to stdout). The default behavior if the output file exists is to skip the conversion; use --force to overwrite.