Skip to content

Instantly share code, notes, and snippets.

@ericbaranowski
Created April 7, 2017 16:59
Show Gist options
  • Save ericbaranowski/51bec24f085ac2d0c133dddcd9574440 to your computer and use it in GitHub Desktop.
Save ericbaranowski/51bec24f085ac2d0c133dddcd9574440 to your computer and use it in GitHub Desktop.
# Search Directory Recursively
import os
import fnmatch
def locate_files(search_directory):
files = []
for root, dirnames, filenames in os.walk(search_directory):
for file in fnmatch.filter(filenames, '*.sh'):
files.append(os.path.join(root, file))
return files
search_path = os.path.expanduser('~/Documents')
file_paths = find_files(search_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment