Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: renaming all files in a directory

by CountZero (Bishop)
on Jun 12, 2012 at 18:49 UTC ( [id://975862]=note: print w/replies, xml ) Need Help??


in reply to Re^2: renaming all files in a directory
in thread renaming all files in a directory

An alternative way to make the "next" directory:
use Modern::Perl; use File::Find::Rule; my $directory = 'c:/data/strawberry-perl/perl/script-chrome'; my $dir_pattern = 'test_'; my $next = ( sort { $b <=> $a } map { /(\d+)$/; $1 } File::Find::Rule->directory ->name( "$dir_pattern*" ) ->in( $directory ) )[0] + 1; mkdir "$directory/$dir_pattern$next", 0755 or die "Could not make dire +ctory $directory/$dir_pattern$next";

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found