473,403 Members | 2,222 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,403 software developers and data experts.

how to search directories under <PATH>

Hi

I have to write a function that returns a list of all directories under
<PATH> (should work on linux and windows). it should be easy to write a
loop that goes through every directory... and so on, but I was wondering
if there's faster/more economic way, something like 'find <PATH> -type d'.
I couldn't find any 'find' module for python.

any ideas?

thanx
--
Haim

Jul 18 '05 #1
3 1652
Haim,

google for python path module

cheers Harald
Jul 18 '05 #2
os.path.exists() is what you want.

Secondly, If you want to traverse path
hierarchy use os.path.walk().

HTH,
Larry Bates
Syscon, Inc.

"Haim Ashkenazi" <ha**@babysnakes.org> wrote in message
news:ma**************************************@pyth on.org...
Hi

I have to write a function that returns a list of all directories under
<PATH> (should work on linux and windows). it should be easy to write a
loop that goes through every directory... and so on, but I was wondering
if there's faster/more economic way, something like 'find <PATH> -type d'.
I couldn't find any 'find' module for python.

any ideas?

thanx
--
Haim

Jul 18 '05 #3
On Sat, 26 Jun 2004 08:21:25 -0500, Larry Bates wrote:
os.path.exists() is what you want.

Secondly, If you want to traverse path
hierarchy use os.path.walk().

it shows I'm a newbie... :)

I already found out that os.walk do exactly what I want:

for root, dirs, files in walk(<PATH>):
for dir in dirs:
list.append(root + dir)

this will generate a list of directories under <PATH>

thanx
--
Haim

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Carsten Kraft | last post by:
Hello Newsgroup, I am searching for function which returns me filename from a string that has the file + filepath. ( string sFile = "C:\DIR\SUBDIR\TEST.XML" => TEST.XML) Is there a...
2
by: Susan Baker | last post by:
Hi, I am (trying) to compile some code I downloaded from the internet. The sources contain references to header files - using the form : #include <pathname/file> If I change the form to...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
0
by: Andrzej Lipski | last post by:
Hello I am developing a Windows Ce 5.0 mobile application. I followed the example shown at : Creating Self-Updating Applications With the .NET Compact Framework...
10
by: Andrew Backer | last post by:
I have a few file:///c:/windows/somewhere style uris that I need to convert to the actual physical path. I am hoping there is a built in way to handle this. I know I can do some text replacing...
1
by: dryajov | last post by:
Hi I'm not sure if this should go here in the first place, this is more likely an ODBC driver issue. I'm having the strangest behavior when trying to do an insert into an access database from a...
3
by: Shinis | last post by:
I developed a site using asp.net with vb script.In local machine its working fine.. But when deployed it shows the following error its my code filepath =...
5
by: Kyle Hayes | last post by:
Is there a way to use the 'r' in front of a variable instead of directly in front of a string? Or do I need to use a function to get all of the slashes automatically fixed? /thanks -Kyle
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.