Skip to content

Instantly share code, notes, and snippets.

@junjizhi
Created December 2, 2019 03:12
Show Gist options
  • Save junjizhi/76db0628f159a8ece0109452b581b833 to your computer and use it in GitHub Desktop.
Save junjizhi/76db0628f159a8ece0109452b581b833 to your computer and use it in GitHub Desktop.
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