http://qs321.pair.com?node_id=1028997


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