[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Recursively visit all files in a directory?



>What is the easiest way to do this?
>
>I could do it myself but surely there must already be a module that does
>this.
>
>Thanks,
>Jim
>
>--
>Jim Correia                                Bare Bones Software, Inc.
>correia@barebones.com                     <http://web.barebones.com>
>

#!perl

use Mac::MoreFiles;

 $folderPath = substr(`pwd`,0,length(`pwd`) - 1) . ':'; # path to folder
that contains this program
 print "$folderPath\n\n";

 FSpIterateDirectory ($folderPath,0,files_in_directory,undef);

sub files_in_directory {
    print "@_\n";
    return 0;
}

__END__

Mac::MoreFiles - Sophisticated file management routines

FSpIterateDirectory SPEC, MAXLEVELS, ITERATEFILTER, YOURDATAPTR

  Iterate (scan) through a directory's content.
  The FSpIterateDirectory function performs a recursive iteration (scan)
  of the specified directory and calls your ITERATEFILTER function once
  for each file and directory found.

  The MAXLEVELS parameter lets you control how deep the recursion goes.
  If MAXLEVELS is 1, FSpIterateDirectory only scans the specified directory;
  if MAXLEVELS is 2, FSpIterateDirectory scans the specified directory and one
  subdirectory below the specified directory; etc. Set MAXLEVELS to zero to
scan all levels.

  The YOURDATAPTR parameter can point to whatever data structure you might want
  to access from within the ITERATEFILTER. Your filter function will be
called as:

    $quit = &$filterFunction(YOURDATAPTR, SPEC);


David Seay
http://www.mastercall.com/g-s/





# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org