How to rename multiple files in terminal (LINUX)?

file, linux, pattern-matching, rename, terminal

Solution

The best way to do this is to run a loop in the terminal going from picture to picture and renaming them with a number that gets bigger by one with every loop.

You can do this with:

n=1
for i in *.jpg; do
    p=$(printf "%04d.jpg" ${n})
    mv ${i} ${p}
    let n=n+1
done

Just enter it into the terminal line by line.

If you want to put a custom name in front of the numbers, you can put it before the percent sign in the third line.

If you want to change the number of digits in the names' number, just replace the '4' in the third line (don't change the '0', though).

Problem

I have bunch of files with no pattern in their name at all in a directory. all I know is that they are all Jpg files. How do I rename them, so that they will have some sort of sequence in their name. I know in Windows all you do is select all the files and rename them all to a same name and Windows OS automatically adds sequence numbers to compensate for the same file name. I want to be able to do that in Linux Fedora but I you can only do that in Terminal. Please, help. I am lost. What is the command for doing this?

Original source