Skip to content

Instantly share code, notes, and snippets.

@mynameisvinn
Forked from tinacious/images.sh
Created August 25, 2014 01:17
# Image processing function
# Usage: In the Terminal, run: bash images.sh
# Get user input and resize images
function process () {
# rename
a=1
for i in *.${ext}
do
new=$(printf "${filename}_%03d.${ext}" ${a}) # %03d = 3 digits
mv ${i} ${new}
let a=a+1
done
# resize
sips -Z ${size} *.${ext}
}
# Interveiw
echo "What would you like the filename to be?"
read filename
echo "What is the file extension of your image? Must be case sensitive (jpg JPG png PNG)"
read ext
echo "What width in pixels would you like your images?"
read size
# Confirm and process
read -p "Your filename will be '$filename' and the width will be $size pixels. Continue? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
process
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment