Skip to content

Instantly share code, notes, and snippets.

@mhammonds
Last active December 10, 2015 15:19
Show Gist options
  • Save mhammonds/4453654 to your computer and use it in GitHub Desktop.
Save mhammonds/4453654 to your computer and use it in GitHub Desktop.
Quick script for prefixing images with Bash.
#!/bin/bash
if [ ! -z "$1" ]
then
PREFIX=$1
else
echo "Enter the filename prefix:"
read PREFIX
fi
shopt -s nullglob
for FILE in *.png *.jpg *.jpeg *.gif
do
echo "Renaming $FILE to $PREFIX$FILE. . ."
mv "$FILE" "$PREFIX$FILE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment