list windows subdirectories

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bmatznick
    New Member
    • May 2007
    • 2

    list windows subdirectories

    I'm obviously new to this so here goes.
    I want to go into a folder on the c drive of windows, this folder has many other folders which have folders inside of them. What I want to do is get the name of every folder and subfolder and put it into an array.
    Is there an easy way to do this?
    Thanks for your help

    BMatz
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    You could use the File::Find module. On windows I prefer to use a shell command:

    Code:
    @files = qx|dir c:\\windows /B /A:D /S /O:N|;
    print @files;
    You can open a dos window and type:

    c:\>dir /?

    to read the "dir" command options

    Or read the File::Find documentation:



    which you can also read locally if you have activestate perl installed on your windows PC.

    Comment

    • bmatznick
      New Member
      • May 2007
      • 2

      #3
      Thanks, that was exactly what I needed!
      If you don't mind I do have one question what does the qx| do? It works fine but I couldn't figure out exactly what that part is doing? Thanks again!!
      BMatz

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        # qx/STRING/
        # `STRING`

        A string which is (possibly) interpolated and then executed as a system command with /bin/sh or its equivalent. Shell wildcards, pipes, and redirections will be honored. The collected standard output of the command is returned; standard error is unaffected. In scalar context, it comes back as a single (potentially multi-line) string, or undef if the command failed. In list context, returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_S EPARATOR), or an empty list if the command failed.


        above quoted from:

        perldoc Perlop Regexp-Quote-Like-Operators

        Comment

        Working...