Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Private Utilities

by Anonymous Monk
on Dec 01, 2005 at 12:02 UTC ( [id://513244]=note: print w/replies, xml ) Need Help??


in reply to Private Utilities

i use this (way to often) to renumber image files so they'll sort in order.
#!/usr/bin/perl # # renum.pl blah*.jpg # blah1.jpg .. blah9.jpg blah10.jpg .. blah99.jpg blah100.jpg # -> blah001.jpg .. blah010.jpg .. blah100.jpg foreach ( @ARGV ) { next unless ($stem, $digits, $ext) = /(.*?)(\d+)\.([^\.]+)$/; $max = $len if ($len = length( $digits )) > $max; print "$_ $1\n"; } $fmt = "$stem\%0${max}d.$ext"; foreach ( @ARGV ) { next unless ($stem, $digits, $ext) = /(.*?)(\d+)\.([^\.]+)$/; $new = sprintf $fmt, $digits; rename $_, $new or warn $!; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://513244]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found