Recursively get all file names from a directory
Recursively get all file names matching a substring from a directory.
Where:
* path = Directory to search
* matchStr = Substring to match
import os import fnmatch def getFiles(path, matchStr): matches = [] for root, dirnames, filenames in os.walk(path): for filename in fnmatch.filter(filenames, matchStr): matches.append(os.path.join(root, filename)) return matches
Leave a comment