I'm pretty new to bash.
I have multiple .png and large .jpg files throughout multiple sub directories
Trying to achieve the following:
1. Convert all .png files to .jpg files throughout all sub directories.
2. Optimize .jpg files for better compression (about 80% quality).
3. Delete all obselete .png files.
I found the following commands to:
1. convert png to jpg (with imagemagick)
Code: Select all
mogrify -format jpg *.png
Code: Select all
jpegoptim *.jpg -m 80
How do I accomplish this? Which way should I pick and how? Couldn't get it to work.
Thanks!
EDIT:
Turns out I had to add "+" at the end of the -exec command following "find".
So it works with the following code, when I run each line seperately:
Code: Select all
find -name *.png -exec mogrify -format jpg {} +
find -name *.jpg -exec jpegoptim -m 80 {} +
find -name *.png -exec rm {} +