Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Resize all image files to half of the sizes
#!/usr/bin/env bash
set -euxo pipefail
# Usage:
# cd /path/to/images/directory
# bash resize.bash
shopt -s extglob
for filename in [^resize]*.?(jpg|jpeg|png); do
newFile="resized-$filename"
if [ ! -f "$newFile" ]; then
convert $filename -resize 50% $newFile
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment