Skip to content

Instantly share code, notes, and snippets.

@yann2192
Created November 25, 2012 17:34
Show Gist options
  • Save yann2192/4144475 to your computer and use it in GitHub Desktop.
Save yann2192/4144475 to your computer and use it in GitHub Desktop.
Find a file in subdir
import os
def findInSubdirectory(filename, 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