Last active
January 1, 2016 09:39
-
-
Save vadimii/8126354 to your computer and use it in GitHub Desktop.
Min-Max file dates in directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, datetime | |
maxm = minm = None | |
for root, dirs, files in os.walk(sys.argv[1] if len(sys.argv) > 1 else '.'): | |
for name in files: | |
path = os.path.join(root, name) | |
mtime = os.path.getmtime(path) | |
maxm = maxm if maxm and maxm > mtime else mtime | |
minm = minm if minm and minm < mtime else mtime | |
def ftime(secs): | |
return datetime.datetime.fromtimestamp(secs).strftime('%Y-%m-%d') | |
print ftime(minm), ftime(maxm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment