Last active
September 28, 2015 03:17
-
-
Save sumitasok/1375769 to your computer and use it in GitHub Desktop.
to number all files in a folder
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
function number_incrementally { | |
i=0 | |
#echo "Prefix if any:" | |
#read prefix | |
#echo "Number starts at(default is 0):" | |
#read i | |
i=$1 | |
prefix=$2 | |
echo "Number Starts at $i with prefix as $prefix" | |
for f in *; do n="$prefix$i - $f"; mv "$f" "$n"; i=`expr $i + 1`;done | |
echo "Last File Name Starts with `expr $i - 1`" | |
} | |
#usage: number_incrementally starting_number prefix_term | |
# to replace all %20 with a blank space | |
for f in *; do n=`echo $f | sed "s/%20/ /g"`; mv "$f" "$n"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment