

I know that threading does not work for nested for loops, so I am stuck in figuring out how to use the multithreading module for this problem. The glob method also supports an extended glob syntax, '/', which allows you to search for files recursively. Searching for Files Recursively in Python.

By changing'' to '.py', we could focus on just the Python files, or specify a full filename, etc. VAR.set(nr) # Set number of files as a variable for label You c n see we list two python files and the subdirectory. Nr = LIST.size() # Get current number of files in listbox LIST.update_idletasks() # Update listbox after each element added LIST.insert(END,f) # Insert path with name string into the listbox If 'COMPARE.mat' in f: # if 'COMPARE.mat' in f and not 'MIN' in f and not 'MAX' in f / if 'COMPARE.mat' in f ) # if 'COMPARE.mat' in f and not 'MIN' in f and not 'MAX' in fįileLevels.append(f.split('/')) # Split path string at all '/' UsePATH = '/nfzcae/nvh_mdp/Messdatenbank_Powertrain'įileLevels = # code of interest is belowįor f in glob.iglob(os.path.join(path, d,'*COMPARE.mat')): The recursive walk() function is passed the name of a base folder to search along with a match function to call for each file in the folder. The code which I wrote is as follows: lete(0,END) # this is a list view Here's another example that was tested, and will match search & replace patterns: import fileinput import sys def replaceAll (file,searchExp,replaceExp): for line in fileinput.input (file, inplace1): if searchExp in line: line line.replace (searchExp,replaceExp) (line) Example use: replaceAll ('/fooBar.txt','Hello\sWorld. I was thinking of multiprocessing or threading. The function which I wrote works, but I want to make it more efficient and faster. I have a directory with lot of files and folders in it.
