Dealing with paths (Unix question)

paul appleseed-cast~NOSPAM~ at breathe.com
Sat Aug 2 23:04:13 EDT 2003


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.




More information about the Python-list mailing list