Created
April 7, 2017 16:59
-
-
Save ericbaranowski/51bec24f085ac2d0c133dddcd9574440 to your computer and use it in GitHub Desktop.
# Search Directory Recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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