Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Directory Crawling

by JKasting (Novice)
on Dec 30, 2009 at 20:42 UTC ( [id://814985]=perlquestion: print w/replies, xml ) Need Help??

JKasting has asked for the wisdom of the Perl Monks concerning the following question:

I need a program that can be executed in the root folder of a directory tree and will go to each of the lowest subfolders in the directory and rename those files in standard RDF format. I can handle the renaming, it's the directory transversing that I don't understand. I appreciate any help!

Replies are listed 'Best First'.
Re: Directory Crawling
by jethro (Monsignor) on Dec 30, 2009 at 20:49 UTC
      I've been looking at that, but am unsure on how to utilize it. I'm wanting to rename files located in many different paths. How can I use File::Find to get to all of them?
        Perhaps Beginners guide to File::Find will help? (Also, it's a little unclear what “many different paths” means—do you want to handle some, but not all, subdirectories of a master directory?)
Re: Directory Crawling
by toolic (Bishop) on Dec 30, 2009 at 21:24 UTC
Re: Directory Crawling
by stefbv (Curate) on Dec 31, 2009 at 06:28 UTC

    Or you can use File::Find::Rule, an "Alternative interface to File::Find".

    use strict; use warnings; use File::Find::Rule; my $pattern = '*.rdf'; my $path = '.'; my @results = File::Find::Rule ->name( $pattern ) ->file ->nonempty ->in( $path ); foreach my $file (@results) { print "$file\n"; }

Log In?
Username:
Password:

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

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

    No recent polls found