Quick optimization of jpeg files in a directory (Linux bash)

Firstly install jpegoptim.

You can do this on Debian like systems using apt:

sudo apt-get update && sudo apt-get install jpegoptim

Then go to directory with jpeg files and use this command:

find . -name '*.jpg' -exec jpegoptim -m70 -o -f --strip-all {} \;

It will find all jpg files recursively and optimize with following settings:

  • m70 stands for jpeg quality (about 70 – 80 should be fine but lossy)
  • o is for overwrite
  • f is for force
  • strip-all removes all EXIF and other textual data from files