12/14/2013 - 1:08 AM

walk around a directory.py

import os
import os.path

def walk(directory, dir_filter=None, file_filter=None):
    """return a list of all files in this directory, sorted"""
    all_files = []
    for root, dirs, files in os.walk(directory):
        dirs[:] = sorted(filter(dir_filter, dirs))
        all_files.extend(map(lambda f: os.path.abspath(os.path.join(root, f)),
                         sorted(filter(file_filter, files))))
    return all_files

for f in walk(
    lambda s: not s.startswith("."),
    lambda s: s.endswith(".xls") and not s.startswith("."),