drilling down into sub-dirs looking for specific files to modify.
glob.glob() to search all sub-dirs for files.
path = 'C:\Test\*\*[1234,349,4568]*.*' #print(path) files = glob.glob(path) print(files) for name in files: with open(name,'r') as inputfile: newText = inputfile.read().replace('5484522-102','P/N 545616-102') print(newText) with open(name, "w") as outputfile: outputfile.write(newText) print('Done !')
modifies the files called out in the path and many more I don't want to be modified. How do i modify only the files called out in the path?