6

I need to excute in ubuntu something like this:

find ./ -name '*.jpg' -execdir "mogrify -quality 50 *.jpg" {} \;

To compact all the *.jpg to 50% of your quality but this need to be recursive, because i have 1350 files in a long tree of folders...

And this return ever something like:

mogrify: unable to open image `Banner-Caixa.jpg': permission denied @ error/blob.c/OpenBlob/2712.
FencherLC
  • 161
  • 1
  • 5

1 Answers1

10

I discovered!

sudo find . -name '*.jpg' -execdir sh -c "mogrify -quality 50 *.jpg" {} \;

This works fine!

widoth / on ./ and add sh -c after -execdir

FencherLC
  • 161
  • 1
  • 5
  • 1
    Thanks! However, you might not need sudo if files are owned by you. – Richi González Aug 14 '19 at 04:05
  • 1
    are you sûre about this command, I gues the ending *.jpg make mogrify look deeply each time I use this one and it works fine: find . -name '*.jpg' -execdir sh -c "mogrify -quality 50 {} " \; – jbdemonte Oct 10 '20 at 22:44
  • The last *.jpg produces a error: Take sudo find . -name '*.jpg' -execdir sh -c "mogrify -quality 50 {}" \; – RubbelDeCatc Nov 16 '21 at 10:10