ls | wc -l #Count files on current directory
ls path/to/dir | wc -l #Count files on specific directory path
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
ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done