0

I'm trying to resize all images in a directory and sub directories. I have this script which I got from here: Use mogrify to resize large files while ignoring small ones

and adjusted to:

identify -format '%w %h %i\n' ./*.jpg |
awk '$1 > 1200 || $2 > 1200 {sub(/^[^ ]* [^ ]* /, ""); print}' |
tr '\n' '\0' |
xargs -0 mogrify -resize '1200x1200'

but it only does the current directory and only .jpg extensions - ignores the upper case - .JPG

I've tried making adjustments but not making much progress.

mmc501
  • 103

1 Answers1

3

You could combine identify with find, for example:

find . -type f -iname "*.jpg" -exec identify -format '%w %h %i\n' {} \;

which will run your identify command for every file recursively found with name ending in .jpg (case-insensitive).

Using your full example:

find . -type f -iname "*.jpg" -exec identify -format '%w %h %i\n' {} \; |
awk '$1 > 1200 || $2 > 1200 {sub(/^[^ ]* [^ ]* /, ""); print}' |
tr '\n' '\0' |
xargs -0 mogrify -resize '1200x1200'
sebasth
  • 14,872