Skip to content

Instantly share code, notes, and snippets.

@wlizama
Last active June 13, 2019 16:36
Show Gist options
  • Save wlizama/cb3771eb4be296d1983f53fc5fd21636 to your computer and use it in GitHub Desktop.
Save wlizama/cb3771eb4be296d1983f53fc5fd21636 to your computer and use it in GitHub Desktop.
import fnmatch
import os
MY_DIR = 'Q:\\my_dir\\sub_dir'
FILE_EXT = 'xml'
def filter_files_by_ext(dir, filter_ext):
files = [file for file in os.listdir(dir) if fnmatch.fnmatch(file, '*.%s' % filter_ext)]
return files
def execute():
print(filter_files_by_ext(MY_DIR, FILE_EXT))
if __name__ == "__main__":
execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment