Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Simple Perl file rename

by agianni (Hermit)
on Aug 14, 2007 at 15:51 UTC ( #632526=note: print w/ replies, xml ) Need Help??


in reply to Simple Perl file rename

If all of your files are in a directory or hierarchy, here's a nice one-liner using File::Find from the command line:

perl -MFile::Find -e 'find sub{ rename $_, (m/.*\s(.*)\z/)[0] }, q{.}'

It's a little obfuscated, but the only part that might be confusing is the pattern match, wrapped with parens with an array index, which simply returns the first result of the match.

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'


Comment on Re: Simple Perl file rename
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-26 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls