I have a for loop that walks through the root directory I give it and recursively looks through all the folders for certain strings in files. However I want to exclude certain folders from being recursively looked at, and to skip their contained files.
I currently have the below that works with the static values, "values-af", "values-am". However I have 91 of "values-##" and so don't want to list all variations. I attempted a reg ex in the variable 'skip' however cannot get this working correctly.
rootpath=outDir
#skip=re.compile('values-([\w])+')
exclude=set(['values-af','values-am'])
for path,name,fname in os.walk(rootpath):
name[:] = [d for d in name if d not in exclude]
[more code]
How would I go about implementing a correct regex in the above code to match anything after the word 'values' eg. values-gf, values-fgh-rHK, values-h24, values-g4dghd
tl;dr got working code but need to implement a working regex to and exclude everything after "values"