in reply to Re^2: RE question; how to insert a digit between const[a-z]*3 && inc[0-9]*3?
in thread RE question; how to insert a digit between const[a-z]*3 && inc[0-9]*3?
Given that context, you might want to try something like this technique (untested):
while (defined($file = readdir(DIR))) { next unless $file =~ /^(abc)(\d{1,3})(\.html)$/; rename "$dirname/$file" "$dirname/" . $1 . "0" x (4 - length $2) . + $2 . $3; }
I'd also recommend that you try this with a print to ensure you're in the right directory and targetting the correct files before making thousands of changes; then change to rename. Some error checking/handling might also be useful.
-- Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: RE question; how to insert a digit between const[a-z]*3 && inc[0-9]*3?
by taint (Chaplain) on Apr 16, 2013 at 22:09 UTC |
In Section
Seekers of Perl Wisdom