$ i=1; for f in *; do mv "$f" "$(printf "%02i%s" "$i" "${f#[0-9][0-9]}")"; ((i++)); done; Ref: https://gist.github.com/larshaendler/3c477182717d32a4fc64070c283d24ad https://unix.stackexchange.com/questions/281794/bash-file-mass-rename-with-counter