Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created February 26, 2010 02:37
Show Gist options
  • Save lxneng/315330 to your computer and use it in GitHub Desktop.
Save lxneng/315330 to your computer and use it in GitHub Desktop.
Find file in subdirectory
import os
def findFileInSubdirectory(filename, subdirectory=''):
'''
Find file in subdirectory
'''
if subdirectory:
path = subdirectory
else:
path = os.getcwd()
for root, dirs, names in os.walk(path):
if filename in names:
return os.path.join(root, filename)
raise 'File not found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment