[Kc] getting all file paths
Doug Ledbetter
dougl at dougledbetter.org
Fri Mar 23 08:02:45 PDT 2007
At 09:08 PM 3/22/2007, you wrote:
>I'm trying to figure out how to find out more about File::Find (like
>what -d does (I'm assuming it means directories), etc).
I don't quite understand what information you're wanting to get about
each file but maybe this information will help:
Variable $File::Find::dir is the full path only to the file
Variable $File::Find::name is the full path and filename
Variable $_ is just the file name
Yes, you were correct that the "-d" test will determine if the file
is a directory. There are several other file tests also.
I don't know if this would help but instead of excluding the files
you don't want to see maybe you could only include the files that you
do want to see. For example:
#!/usr/bin/perl -w
use File::Find;
# only display .mp3 files
find(sub { if ($_ =~ m/\.mpg$/i) { print "$File::Find::name\n" } },
"/Users/jay/Desktop/song files/");
>Also, is there a limit as to how many files you can find? Does it
>just depend on how much memory your machine has?
I suppose you could run out of resources if you wrote the script
right but generally speaking I think it returns one file at a time so
I don't think there's a problem with memory.
I hope this helps!
-dougl
____________________________________________________________
Doug Ledbetter
dougl at dougledbetter.org
http://www.dougledbetter.org/
My PGP Public Key: http://dougledbetter.org/public_key.html
More information about the kc
mailing list