Skip to content

Instantly share code, notes, and snippets.

@keitaoouchi
Created April 5, 2012 02:45
Show Gist options
  • Save keitaoouchi/2307608 to your computer and use it in GitHub Desktop.
Save keitaoouchi/2307608 to your computer and use it in GitHub Desktop.
Recursive directory listing with ignore pattern.
import os
def recursive_listing(root, ignoredirs=None, ignorefiles=None):
result = []
ignoredirs = ignoredirs or []
ignorefiles = ignorefiles or []
for dir, subdirs, fnames in os.walk(root):
if all(map(lambda d: d not in dir, ignoredirs)):
for name in fnames:
if all(map(lambda f: f not in name, ignorefiles)):
result.append("{0}/{1}".format(dir, name))
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment