listing files in sub directories

Discussion in 'Perl Misc' started by steve, Mar 9, 2009.

  1. steve

    steve Guest

    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!
    steve, Mar 9, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Finkel
    Replies:
    0
    Views:
    482
    Joel Finkel
    Sep 12, 2003
  2. salvo
    Replies:
    12
    Views:
    4,890
    Ron Natalie
    Feb 2, 2005
  3. Ben
    Replies:
    2
    Views:
    859
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,963
    Lawrence D'Oliveiro
    May 20, 2011
  5. Ron Smith
    Replies:
    5
    Views:
    136
    Michele Dondi
    Nov 2, 2004
Loading...

Share This Page