Given the following piece of python code:
for root, dirs, files in os.walk(directory): for filename in fnmatch.filter(files, \'*.png\'): pass
Please try this:
# pattern_list = ['*.jpg', '__.*'] def checkFilepatter(filename, pattern_list): for pattern in pattern_list: if fnmatch.fnmatch(filename, pattern): return True return False