Shell: Batch Renaming with Counter
Here's a script that allows you to rename JPG files while adding a counter:
| export j=0 # export is only useful if you're working in interactive mode (not in a script)
for i in *.JPG ; do
mv $i `echo $i | sed s/^/$j\ -\ /`
j=$((j+1))
done
|
Here's a faster method for renaming files:
Instead of typing:
| mv my_file.txt my_file.that_i_want_to_backup
|
You can simply do:
| mv my_file.{txt,that_i_want_to_backup}
|