Thanks for these! Here's my version.
For images.
This code will just rename all files in given folder to 0,1,2,3,4 .jpg
WARNING, usage:
/path/to/batchrename /PATH/TO/FILES/
Code:
#!/bin/bash
#regexp rename utility with renumbering of groups of files
#files with the same portion anywhere in the filename can be numbered anywhere in the filename
#in dsl linux shell
dir=$1
i=0
ls "$dir" | while read file; do
echo old $file
newname=`echo "$i.jpg"`
let "i=$i+1"
echo new $newname
mv "$dir/$file" "$dir/$newname"
echo "------------------------------------"
done
#renames files like
# 1989 112200 corio.jpg
# 1989 112201 corio.jpg
# 1990 112300 corio.jpg
#to
# 1989 011000 corio.jpg
# 1989 012000 corio.jpg
# 1990 011000 corio.jpg
#that is, renumbers files starting with 11000 each new year. increment is 1000.
#order doesn't change
#remember chmod +x foo.sh
#thx to jamiew for Handling filenames with spaces in a bash for loop