Hi, can anyone help me with a bash script to give sensible names to a large number of photos. I hope to be able to run a script with an argument which will become the filename followed by a number beginning at 1. I'm hoping for something that works along the lines of
Code:
./file_rename.sh Summer2009_
Summer2009_0001
Summer2009_0002
Summer2009_0003
I'm new to Linux and have so far managed to write the following script which doesn't quite produce the result I'm looking for.
Code:
#!/bin/bash
#file_rename.sh
FILE_LIST=`ls`
a="1"
for i in $FILE_LIST; do
mv $i $1_$a.JPG
a=$[$a+1]
done
exit 0
The problem with this is that the files are then listed in the following order:
Summer2009_1
Summer2009_10
Summer2009_2
Any help would be much appreciated.
Thanks.