Front page | perl.perl6.language | Postings from March 2009

## listing all files in all sub directories

From:
steve
Date:
March 10, 2009 00:16
Subject:
listing all files in all sub directories
Message ID:
I am trying to list all files in all sub-directories and have the code
below but this is listing the . directories as well as the directories
themselves. I just want the full path filenames and not the individual
directories out. Here is what I have

#!c:/Perl/bin/Perl.exe

@ARGV = qw(.) unless @ARGV;

use File::Find;

find sub { print \$File::Find::name, -d && "/", "\n"}, @ARGV

for example if structure is
c:\file.txt
c:\file2.txt
c:\one\teo.txt
c:\two\text.bmp

the output of the script when run from c:\ would be
./
./script.pl
./file.txt
./file2.txt
./one/
./one/teo.txt
./two/
./two/text.bmp

all I want is
./script.pl
./file.txt
./file2.txt
./one/teo.txt
./two/text.bmp

Thanks!


• listing all files in all sub directories by steve

nntp.perl.org: Perl Programming lists via nntp and http.