What is the best way, using Bash, to rename files in the form:
(foo1, foo2, ..., foo1300, ..., fooN)
With zero-padded file names:
(foo00001, foo00002, ..., foo01300, ..., fooN)
It's not pure bash, but much easier with the Perl version of rename:
rename
rename 's/d+/sprintf("%05d",$&)/e' foo*
Where 's/d+/sprintf("%05d",$&)/e' is the Perl replace regular expression.
's/d+/sprintf("%05d",$&)/e'
d+
sprintf("%05d",$&)
sprintf
%05d
2.1m questions
2.1m answers
60 comments
57.0k users