Created
April 15, 2011 16:16
-
-
Save rafaelrinaldi/921973 to your computer and use it in GitHub Desktop.
Helpful for when you want to change the name of a sequence of images at the same time.
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
# /bin/bash | |
# | |
# Helpful for when you want to change the name of a sequence of images at the same time. | |
# | |
# Author: Rafael Rinaldi (rafaelrinaldi.com) | |
# Since: 15/04/2011 | |
# | |
path=$1 | |
base_name=$2 | |
count=0 | |
if [[ ! -d $path ]]; then | |
echo "Invalid path!"; | |
exit; | |
fi | |
for file in $path/*.* | |
do | |
# Keep the same extension of the original one. | |
extension=`echo $file | awk -F . '{print $NF}'`; | |
mv "$file" "$path/$base_name$count.$extension"; | |
(( count++ )); | |
done |
Cool! Thanks for sharing :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in ruby