Last active
August 29, 2015 14:03
-
-
Save sbp/28336e03b08a58ff4d8f to your computer and use it in GitHub Desktop.
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 | |
import sys | |
def main(): | |
root = sys.argv[1] | |
if not os.path.isdir(root): | |
print("Not a directory:", root) | |
sys.exit(1) | |
for (r, d, f) in os.walk(root): | |
directories = [(os.path.join(r, dn), "d") for dn in d] | |
filenames = [(os.path.join(r, fn), "f") for fn in f] | |
for (p, k) in directories + filenames: | |
p = os.path.abspath(p) | |
try: stat = os.lstat(p) | |
except OSError: | |
continue | |
args = (k, int(stat.st_size), int(stat.st_mtime), p) | |
entry = "%s %s %s %s" % args | |
try: print(entry) | |
except IOError: | |
sys.exit(0) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment