bash - How to match numbering of files across different folders e.g. rename NAME9.txt to NAME00009.txt -


i have huge list of files, came through different processes, reason ones in first folder numbered this

a9.txt a1.txt while ones in other have a00009.txt a.00001.txt have no more 99837 files only 4 "extra" 0 on 1 side.

i need rename files inside 1 folder names matches. there way in loop? help.

you should take @ perl-rename (sometimes called rename) not confused rename util-linux.

perl-rename 's/\d+/sprintf("%05d", $&)/e' *.txt 

the above script rename .txt files in directory following:

a1.txt       -> a00001.txt a10.txt      -> a00010.txt hello225.txt -> hello00225.txt 

test online


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo