Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, stat, time
- from datetime import date, timedelta
- # Directory
- def direc(path, howold):
- foundt = 0
- for root, paths, files in os.walk(path):
- # print "root: ", root
- # print "paths: ", paths
- # print "files: ", files
- count = 1
- for i in files:
- # print os.path.join(root, i)
- found = oldfile(root, i, howold)
- if not found:
- foundt = 0
- if foundt:
- print root, files
- def oldfile (root, i, age):
- compdate = date.today() - timedelta(days=age) # needs minus one day
- fullname = os.path.join(root, i)
- used = os.stat(fullname).st_mtime
- yr, dy, mnth = time.localtime(used)[:3]
- lastmod = date(yr, dy, mnth)
- if lastmod < compdate:
- return 1
- return 0
- path = "/home/slot/Desktop"
- howold = "1"
- direc(path, int(howold))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement