Skip to main content
edited title
Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 239

Bash Script To Minfiyscript to minify PNG's keeps stopping

Source Link

Bash Script To Minfiy PNG's keeps stopping

I have tried to run this script a few times now and it keeps hanging. I have 60,000 images and it goes through about a 1000 and then stops. I have been running the top command and the process pngquant dissapears it seems. Any help would be much appreciated.

The last output I got was

Optimized PNG: ./12/thumbnail/112.png
Optimized PNG: ./12/thumbnail/photography.png
Optimized PNG: ./12/thumbnail/Christmas-01.png
Optimized PNG: ./12/thumbnail/OA1920.png
error: cannot open ./12/thumbnail/The for reading
Optimized PNG: ./12/thumbnail/The
error: cannot open Official for reading
Optimized PNG: Official
error: cannot open AndreasCY for reading
Optimized PNG: AndreasCY

And then it stopped. The script looks like this.

#!/bin/bash

cd /var/www/html/wp-content/uploads/2014/

for PNG in $(find . -name '*.png'); do

  pngquant --ext .png --force 256 ${PNG}
  echo "Optimized PNG: ${PNG}"

done