473,395 Members | 1,974 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,395 software developers and data experts.

Dealing with paths (Unix question)

hey there all!
i'm writing some little programs, and i'd like to know about how to deal
with directories on unix. i've read up on this, but the docs don't really
mention much on it. do i use the pickle module, or something?

what i'd like to do is read in a path, say
/home/username/images/
and that path contains a dir called downloads and some png files,
and it also contains another dir called icons, which holds jpg, png and
gif files.
Now, is it posible to go through that top directory and recursively go
through /icons/ and /downloads/ and pick out all files of a certain
extension(only png files, for example)?

something like:
for each_file in /home/username/images:
if image_extension is png:
add image path to list
but as i said, i need something to work recursively though an arbitrary
number of directories.

sorry if i wan't too clear here :/
if anyone can post some clues on the modules/methods i'd use, and maybe
some example code, that'll be *very* much appreciated!

thanks for reading.
paul.
Jul 18 '05 #1
4 1665
On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:
hey there all!
i'm writing some little programs, and i'd like to know about how to deal
with directories on unix. i've read up on this, but the docs don't really
mention much on it. do i use the pickle module, or something?


Look at os.path.walk
--
Visit my blog - http://blog.scalegen.com
Music, Programming, and More.

Jul 18 '05 #2
Or os.walk, that might be easier for a beginner. I think that's new though
in 2.3.

"Tyler Eaves" <ty***@scalegen.com> wrote in message
news:pa****************************@scalegen.com.. .
On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:
hey there all!
i'm writing some little programs, and i'd like to know about how to deal
with directories on unix. i've read up on this, but the docs don't really mention much on it. do i use the pickle module, or something?


Look at os.path.walk
--
Visit my blog - http://blog.scalegen.com
Music, Programming, and More.

Jul 18 '05 #3
On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:
hey there all!

<snip>

cheers for the replies Tyler, Bjorn and Andy. I'll be checking out
os.path, etc...

fun fun fun...
paul.

Jul 18 '05 #4
paul <ap********************@breathe.com> wrote in message news:<pa***************************@breathe.com>.. .
hey there all!
i'm writing some little programs, and i'd like to know about how to deal
with directories on unix. i've read up on this, but the docs don't really
mention much on it. do i use the pickle module, or something?

what i'd like to do is read in a path, say
/home/username/images/
and that path contains a dir called downloads and some png files,
and it also contains another dir called icons, which holds jpg, png and
gif files.
Now, is it posible to go through that top directory and recursively go
through /icons/ and /downloads/ and pick out all files of a certain
extension(only png files, for example)?

something like:
for each_file in /home/username/images:
if image_extension is png:
add image path to list
but as i said, i need something to work recursively though an arbitrary
number of directories.

sorry if i wan't too clear here :/
if anyone can post some clues on the modules/methods i'd use, and maybe
some example code, that'll be *very* much appreciated!

thanks for reading.
paul.


You may also want to look at this recipe:

http://aspn.activestate.com/ASPN/Coo.../Recipe/212959

M.S.
Jul 18 '05 #5

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

Similar topics

5
by: Noah | last post by:
Does anyone have a function to convert back and forth between NT style paths and POSIX style? It seems trivial, but I want to make sure I don't overlook some obscure detail. Is it a simple matter...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
1
by: vck_82 | last post by:
HI Does any body know how to convert windows style path to posix style path. I need this because i am developing a windows application which actually starts an exe which is developed in unix....
5
by: Shane Thomas | last post by:
Hello, I'm having difficulty handling cookies with paths other than "/". An HttpWebRequest object returns these headers: Date: Tue, 26 Apr 2005 21:29:39 GMT Server: Apache/1.3.33 (Unix)...
3
by: dkacher | last post by:
Hi - I'm looking for a way to generate a list of the fully-qualified paths to all of the leaf nodes in an XML Schema. The reason: I have a large schema for which I'm building a transform...
3
by: Jeff | last post by:
I don't have much knowledge of javascript, but need to place a very small amount in a web page. I figured out everything other than how to properly call a page in another folder/directory....
3
by: Pat | last post by:
Hi - We're trying to set up an HADR pair on two databases on instances with different names on separate servers. The databases were defined as follows: CREATE DATABASE database1 ON...
6
by: Jon Slaughter | last post by:
do I have to prefix every absolute path with document root to get it to work? For some reason I thought that prefixing a path with '/' or './' with make it absolute w.r.t to document root but I...
5
by: antar2 | last post by:
Hello, I would like to read and print files, of which the complete filepaths are mentioned in another textfile. In this textfile (list.txt) are for example the following paths: ...
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
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
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...
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,...

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.