Traversing A Directory For Files

Fredrik Lundh fredrik at effbot.org
Sun Jan 21 05:02:23 EST 2001


Ben wrote:
> I am looking for examples of a recusive Python algorithm to traverse a
> directory and all subdirectories for files and return them to a list for
> further processing.

os.path.walk

(you'll find sources in posixpath.py/ntpath.py)

here's a non-recursive version that's much easier to use:

    http://www.deja.com/=dnc/getdoc.xp?AN=695333869

Hope this helps!

Cheers /F





More information about the Python-list mailing list