os.walk trouble

BartlebyScrivener rpdooling at gmail.com
Thu Jun 1 14:21:28 EDT 2006


> As my first Python script, I am trying to make a program that recurses
> a directory searching for files whose names match a pattern. I have a
> basic idea of what the regexp would look like

You probably don't need regexp for this, just use the fnmatch module

http://docs.python.org/lib/module-fnmatch.html

There's a great recipe in the Python Cookbook 2ed for just what you're
trying to do. In fact, I believe there's a recipe in there for just
about anything anybody (at the beginner or intermediate level) wants to
do with Python.

The recipe, with some other unrelated problems:

http://tinyurl.com/nvmzg

Amazon Python Cookbook link:

http://www.amazon.com/exec/obidos/asin/0596007973/inscape-20

good luck

rick




More information about the Python-list mailing list