glob() that traverses a folder tree

seannakasone at yahoo.com seannakasone at yahoo.com
Thu May 11 01:13:59 EDT 2006


# i'm guessing os.walk() is the best way to traverse folder trees.

import os, glob

for dir, subdir, files in os.walk('.\InteropSolution'):
   for file in files:
      if glob.fnmatch.fnmatch(file,"*.dll") or
glob.fnmatch.fnmatch(file,"*.exe"):
         print dir+file




More information about the Python-list mailing list