473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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
May 7 '07 #1
3 3153
KevinADC
4,059 Expert 2GB
You could use the File::Find module. On windows I prefer to use a shell command:

Expand|Select|Wrap|Line Numbers
  1. @files = qx|dir c:\\windows /B /A:D /S /O:N|;
  2. print @files;  
You can open a dos window and type:

c:\>dir /?

to read the "dir" command options

Or read the File::Find documentation:

http://perldoc.perl.org/File/Find.html

which you can also read locally if you have activestate perl installed on your windows PC.
May 7 '07 #2
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
May 8 '07 #3
KevinADC
4,059 Expert 2GB
# 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_SEPARATOR), or an empty list if the command failed.


above quoted from:

perldoc Perlop Regexp-Quote-Like-Operators
May 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Stephen Ferg | last post by:
I have a question that is not directly Python-related. But I thought I'd ask the most erudite group that I know... :-) When did Windows start accepting the forward slash as a path separator...
1
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to...
6
by: Dilip | last post by:
hi all I have created a Windows explorer in VB dot net windows application in Visual studio 2003 where i can browse complete system and able to show all possible SubDirectories of...
3
by: Smith | last post by:
Hi I've installed my web app on windows 2003 and when I run the application I got the follow error: "Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
2
by: kamalak | last post by:
hi, can someone help me in writing code in C# for getting the no of files in a directory and all its subdirectories and their subdirectories where the no of subdirectories and their...
9
by: smoothoperator12 | last post by:
Hi all, I have spent hours trying to figure out where I have went wrong with my code for my recursive function to list all the files in a directory, and all of the files in all of its...
10
by: imfanee | last post by:
Hi ALL, I want to read list of all subdirectories in an array in perl. I know how to get a list of all files in a directory but it does not show subdirectories in that list. Can any help out on...
9
by: kkhan5000 | last post by:
Hello, I am new to PHP and have put together the following code just by copying other examples from the web. Now I am stuck and would like to sort and display files alphabetically, and also filter...
10
by: beary | last post by:
Hello all, I've done something a bit stupid and am hoping some kind soul out there can help me out. There's a piece of code that goes through and creates a high number of subdirectories within...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.