Skip to content

Instantly share code, notes, and snippets.

@JeonghunLee
Last active November 27, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeonghunLee/a81f9ab3531bb3149dfb699e47335901 to your computer and use it in GitHub Desktop.
Save JeonghunLee/a81f9ab3531bb3149dfb699e47335901 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# rename jpg files in sequence with same pattern
#
# Author : Jeonghun Lee
# Version : 0.1
#
# ./rename.sh
# or
# ./rename.sh 1stArg 2ndArg
CNT=0
PREFIX=${1:-"image_"}
POSTFIX=${2:-".jpg"}
echo -e "\e[91mStart: rename all jpg files to ${PREFIX}x${POSTFIX}\e[39m\n"
for FILE in *$POSTFIX
do
NAME=${PREFIX}${CNT}${POSTFIX}
echo -e "ORG:$FILE \e[34m NEW:$NAME \e[39m Index:$CNT"
mv $FILE $NAME
CNT=$((CNT+1))
done
echo -e "\e[91mfinished \e[39m\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment