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 (Priest) 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"; }