2020-12-19 16:15:45 +01:00
|
|
|
#!/usr/bin/env bash
|
2021-05-31 23:59:13 +02:00
|
|
|
set -euo pipefail
|
2020-12-19 16:15:45 +01:00
|
|
|
if (( $# < 2 )); then
|
|
|
|
echo "USAGE: $0 DIGITS FILES"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
digits="$1"
|
|
|
|
shift 1
|
|
|
|
i=1
|
2021-05-31 23:59:13 +02:00
|
|
|
for file in "$@"; do
|
|
|
|
file="$(readlink -f "$file")"
|
|
|
|
mv -n "$file" "${file%/*}/$(printf "%0${digits}d" "$i").${file##*.}"
|
2020-12-19 16:15:45 +01:00
|
|
|
i="$((i+1))"
|
|
|
|
done
|