Created
October 12, 2018 19:51
-
-
Save palamago/f0eb0cd00fe1beee3e78101ab2358e67 to your computer and use it in GitHub Desktop.
Iterate recursively over folders and convert every image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function loop() { | |
shopt -s nullglob | |
for dir in $1/*/ | |
do | |
dir=${dir%*/} | |
if [ -d "$dir" ] | |
then | |
echo "FOLDER-> $dir" | |
for file in $dir/*.jpg | |
do | |
echo " FILE-> $file" | |
convert -contrast -gravity center -resize 340x220\^ -extent 340x220 -background white -colorspace RGB -quality 75 -format jpg $file $file | |
done | |
loop "$dir" | |
fi | |
done | |
} | |
loop "$PWD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment