list number of files in directory code example Example: number all files in a folder ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done