Hugolpz
Hugolpz

Reputation: 18248

Batch resize images within folders and keep folders structure?

I have a folder of HD images, +2000px width :

+ /img/
   +- /bikes/: few images here (jpg,png,svg)
   +- /cars/ : few images here
   +- /cats/ : few images here
   +- /dogs/ : few images here
   +- /...

I would like to bach resize the whole into 200px width images (same ratios) yet keep the folder structure.

How to do so ?

Upvotes: 0

Views: 1424

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207465

You can do something like this, but please make a backup first!

find . -depth -type d \! -name '.' -exec bash -c 'cd $0 || exit; mkdir thumbs 2> /dev/null; shopt -s nullglob; mogrify -path thumbs -resize 200x *.jpg *.svg *.png ' {} \;

which will get you a subdirectory called thumbs in each directory with the smaller versions in there

Upvotes: 2

Related Questions