Suppose you have 2000 photos in a directory and you need to rename them. The files are named as:
IMG_1232.JPG
SP234324.JPG
webdown.JPG
...
We need to rename them as follows:
salzburg_1.jpg
salzburg_2.jpg
...
Here is how:
j=1
s=salzburg_
for f in *.JPG; do
mv $f $s$j.jpg
j=(($j+1))
echo renaming $f to $s$j.jpg
done
j in is the counter. Line 5 increments j. s is a string. Line 4 uses the mv command renaming each file to the desired combination of text and number. Line 6 prints a message on the command line. Note that in line 3, we only loop through files ending in .JPG.