how to rename files in ascending order code example
Example 1: number all files in a folder
a=1
for i in *.jpg; do
new=$(printf "%04d.jpg" "$a") #04 pad to length of 4
mv -i -- "$i" "$new"
let a=a+1
done
Example 2: number all files in a folder
ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done