Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created April 29, 2010 16:35
Show Gist options
  • Save bebraw/383857 to your computer and use it in GitHub Desktop.
Save bebraw/383857 to your computer and use it in GitHub Desktop.
import glob
# let's find all js files in the src sibling directory (not recursive!)
for file_path in glob.iglob('../src/*.js'):
print file_path
import fnmatch
import os
def locate(pattern, root=os.curdir):
'''Locate all files matching supplied filename pattern in and below
supplied root directory.
Original version: http://code.activestate.com/recipes/499305/
'''
for path, dirs, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename)
# let's find all js files in the src sibling directory (recurses!)
for file_path in locate('*.js', '../src'):
print file_path # this should print whole path to the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment