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
# 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