Last active
December 25, 2015 11:19
-
-
Save mchow01/6968354 to your computer and use it in GitHub Desktop.
This shell script will batch create image thumbnails, 100x100, preserving aspect ratio, for images in a directory of images. imagemagick is required! To run: bash ./batch_thumbnail_creator.sh
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/sh | |
for filename in * | |
do | |
if [ "$filename" != "cache" -a "$filename" != "create_cache.sh" -a ! -f "cache/${filename}" | |
]; then | |
mkdir "cache/${filename}" | |
fi | |
done | |
for filename in **/* | |
do | |
thebasename="${filename%.*}" | |
extension="${filename##*.}" | |
thumbname="cache/${thebasename}-thumb.${extension}" | |
if [ "$extension" == "jpg" -o "$extension" == "png" -o "$extension" == "jpeg" ]; then | |
convert "${filename}" -thumbnail '100x100' "${thumbname}" | |
fi | |
done | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment