Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Directory Crawling

by JKasting (Novice)
on Dec 30, 2009 at 20:42 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-05-17 00:41 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (152 votes). Check out past polls.