Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sbalaji6/79eb51a0dd0c361a6287c5a159a73e5f to your computer and use it in GitHub Desktop.
Save sbalaji6/79eb51a0dd0c361a6287c5a159a73e5f to your computer and use it in GitHub Desktop.
import os
import fnmatch
def recursive_glob(rootdir='.', pattern='*'):
"""Search recursively for files matching a specified pattern.
Adapted from http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
"""
matches = []
for root, dirnames, filenames in os.walk(rootdir):
for filename in fnmatch.filter(filenames, pattern):
matches.append(os.path.join(root, filename))
return matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment