So there's another rename command on some systems. It comes with util-linux
and is much shittier to than the perl version as it cannot use regular
expressions.
rename numbered files with padded zeros
perl-rename 's/\d+/sprintf("%04d",$&)/e' *.pdf
[INPUT]
1_Foreword.pdf
2_How_to_Use_This_Manuals.pdf
3_Specifications.pdf
4_Precaution.pdf
5_Note.pdf
6_Identification.pdf
7_Recommended_Materials.pdf
8_Pre-delivery_Inspection.pdf
[OUTPUT]
0001_Foreword.pdf
0002_How_to_Use_This_Manuals.pdf
0003_Specifications.pdf
0004_Precaution.pdf
0005_Note.pdf
0006_Identification.pdf
0007_Recommended_Materials.pdf
0008_Pre-delivery_Inspection.pdf
recursively in a bunch of subdirectories
#!/bin/bash
# iterate over directories
shopt -s globstar
dd=$( pwd )
for dir in "$@"/**/; do
cd "$dd"/"$dir" && perl-rename 's/\d+/sprintf("%04d",$&)/e' ./*.pdf
done
shopt -u globstar