Created
September 14, 2013 21:48
-
-
Save laserson/6565965 to your computer and use it in GitHub Desktop.
Find the most recently modified file in the current 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
| #! /usr/bin/env python | |
| import os | |
| import time | |
| times = [] | |
| for tup in os.walk('.'): | |
| for f in tup[2]: | |
| if f.strip() == '.DS_Store': | |
| continue | |
| path = os.path.join(tup[0], f) | |
| s = os.stat(path) | |
| times.append((path, s.st_mtime)) | |
| result = max(times, key=lambda x: x[1]) | |
| print result[0] | |
| print time.ctime(result[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment