Skip to content

Instantly share code, notes, and snippets.

@sumitasok
Last active September 28, 2015 03:17
Show Gist options
  • Save sumitasok/1375769 to your computer and use it in GitHub Desktop.
Save sumitasok/1375769 to your computer and use it in GitHub Desktop.
to number all files in a folder
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