Recurse Directories and process files in directory
David Lewis
DavidMLewis at mac.com
Sat Aug 12 20:47:32 EDT 2006
On 2006-08-12 09:46:54 -0700, "KraftDiner" <bobrien18 at yahoo.com> said:
> Hi I need help writing a python script that traverses (recursivly) a
> directory and its sub directories and processes all files in the
> directory.
In addition to os.walk, I find Jason Orendorff's 'path' module very
helpful and much easier to use. You can get at
<http://www.jorendorff.com/articles/python/path/>. With it, for
instance, processing all the C source files in a directory,
recursively, would look like:
theDir = path('pathToDir')
for theFile in theDir.walkFiles('*.c'):
# Do something
Best,
David
More information about the Python-list
mailing list