I am trying to resize all files that are found using a FIND command (they are all files within a directory and its subdirectories). I tried many options but stumble across different errors each time. This is my last attempt:
find /my/folder/ -name '*jpg' -exec 'mogrify -resize 900">"{}' \;
I tried many others but to no avail. What goes wrong?
Best Answer
I don't like exec on find very much, it's a bit ancient and unpredictable specially when you feed it all the quotes :)
Try using xargs, it should behave a bit more civilized
find /my/folder/ -name '*jpg' -print0 | xargs -0 -J% "mogrify -resize 900 > %"
Things that are different here
-print0 on find appends a NULL character after each filename as separator
in xargs
-0 tells that the input is separated by NULL char -J% says that % should be replaced by the content in the input (filename in this case)