Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GenevieveBuckley/e11a3c4043797f9ccaa2172847793aeb to your computer and use it in GitHub Desktop.
Save GenevieveBuckley/e11a3c4043797f9ccaa2172847793aeb to your computer and use it in GitHub Desktop.
Find files matching a specific file extension, via recursive search through input directory.
def find_filenames(input_directory, file_extension):
"""Return list of filenames matching file extension."""
filelist = []
for root, _, files in os.walk(input_directory):
for file in files:
if file.endswith(file_extension):
filename = os.path.join(root, file)
filelist.append(filename)
return filelist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment