Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Rename All Files In a Directory

by aukjan (Friar)
on Jul 01, 2005 at 09:33 UTC ( [id://471614]=note: print w/replies, xml ) Need Help??


in reply to Rename All Files In a Directory

You are also trying to rename the directories and anything else listed (and matched) in that directory. (such as '..'). This is probably not what you want to do:

Try this to read in only the files.
@files = grep { -f "$dir/$_" } readdir(DH);
UPDATE: Or in chapter 9.5 of the Cookbook:
use DirHandle; sub plainfiles { my $dir = shift; my $dh = DirHandle->new($dir) or die "can't opendir $dir: $!"; return sort # sort pathnames grep { -f } # choose only "plain" files map { "$dir/$_" } # create full paths grep { !/^\./ } # filter out dot files $dh->read(); # read all entries }

also please do not link to 'illegal' copies of books here...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-18 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found