On May 10, 6:08 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 10 May 2007 19:04:30 -0300, fscked <[EMAIL PROTECTED]> > escribió: > > > > > > > ok, I lied, it is still doing the archived folders. Here is the code: > > > import os, sys > > from path import path > > > myfile = open("boxids.txt", "r", 0) > > for line in myfile: > > d = 'D:\\Dir\\' + path(line.strip()) > > for f in d.walkfiles('*Config*.xml'): > > for dirpath, dirnames, filenames in os.walk(d): > > if "Archived" in dirnames: > > dirnames.remove("Archived") #skip this directory > > print f > > print 'Done' > > > when it does the print f it still shows me the dirs i don't want to > > see. > > You are walking the directory structure *twice*, using two different > methods at the same time. Also, there is no standard `path` module, and > several implementations around, so it would be a good idea to tell us > which one you use. > If you want to omit a directory, and include just filenames matching a > pattern: > > import os, sys, os.path, fnmatch > > def findinterestingfiles(root_dir): > for dirpath, dirnames, filenames in os.walk(root_dir): > if "Archived" in dirnames: > dirnames.remove("Archived") > for filename in fnmatch.filter(filenames, '*Config*.xml'): > fullfn = os.path.join(dirpath, filename) > print fullfn > > myfile = open("boxids.txt", "r") > for line in myfile: > dirname = os.path.join('D:\\Dir\\', line.strip()) > findinterestingfiles(dirname): > myfile.close() > > -- > Gabriel Genellina- Hide quoted text - > > - Show quoted text -
Should this code work? I get a syntax error and cannot figure out why. -- http://mail.python.org/mailman/listinfo/python-list