Renaming Files in a folder to Sequential Numbers with a Prefix

First of all, we have to order our files using ls -v and concatenate them to a standar output with cat -n. From this ouput we read the sequence (n) and the name of each file (f). Finally, we rename the files using mv, adding a prefix and the sequence (n)

ls -v | cat -n | while read n f; do mv "$f" "prefix$n.jpg"; done

If we want to add a zero pad (p) to our sequence (n) we can do it easily with printf.

ls -v | cat -n | while read n f; do printf -v p %03d $n; mv "$f" "prefix$p.jpg"; done