Skip to content

Instantly share code, notes, and snippets.

@TzuChiehHung
Last active September 23, 2019 00:47
Show Gist options
  • Save TzuChiehHung/76fdcde9daf3ab4d1bd95897b9b072ed to your computer and use it in GitHub Desktop.
Save TzuChiehHung/76fdcde9daf3ab4d1bd95897b9b072ed to your computer and use it in GitHub Desktop.
[Get a filtered file list in a directory] #python
import os
from fnmatch import fnmatch
for path, _, files in os.walk('root/dir'):
for filename in files:
if fnmatch(filename, 'match_pattern'):
print(os.path.join(path, filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment