Skip to content

Instantly share code, notes, and snippets.

@lwzm
Last active December 31, 2015 07:29
Show Gist options
  • Save lwzm/7954352 to your computer and use it in GitHub Desktop.
Save lwzm/7954352 to your computer and use it in GitHub Desktop.
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("."),
):
print(os.path.getmtime(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment