Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: File Name Pattern

by dingus (Friar)
on Dec 14, 2002 at 17:27 UTC ( [id://219872]=note: print w/replies, xml ) Need Help??


in reply to File Name Pattern

use File::Dosglob; $dir = '/path/to/dir'; my @m = File::DosGlob::doglob(1,$dir.'/*'); # trailing /* is vital! for (@m) { next unless m!/(\d*)(\d{3}\.jpg)$!; # skip files which do not h +ave at least 3 nos and .jpg my $sub = ('0'x(3-length($1))).$1; # append 0s if req'd my $rest= $2; mkdir ($dir.$sub) unless -e ($dir.$sub); # create dir if req'd rename $_, $dir.$sub.'/'.$sub.$rest; # move file using rename }
*untested code

Dingus


Enter any 47-digit prime number to continue.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-03-28 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found