Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import os, stat, time
  2. from datetime import date, timedelta
  3.  
  4. # Directory
  5. def direc(path, howold):
  6.     foundt = 0
  7.     for root, paths, files in os.walk(path):
  8. #       print "root: ", root
  9. #       print "paths: ", paths
  10. #       print "files: ", files
  11.         count = 1
  12.         for i in files:
  13. #           print os.path.join(root, i)
  14.             found = oldfile(root, i, howold)
  15.             if not found:
  16.                 foundt = 0
  17.         if foundt:
  18.             print root, files
  19.  
  20. def oldfile (root, i, age):
  21.     compdate = date.today() - timedelta(days=age) # needs minus one day
  22.     fullname = os.path.join(root, i)
  23.     used = os.stat(fullname).st_mtime
  24.     yr, dy, mnth = time.localtime(used)[:3]
  25.     lastmod = date(yr, dy, mnth)
  26.     if lastmod < compdate:
  27.         return 1
  28.     return 0
  29.  
  30. path = "/home/slot/Desktop"
  31. howold = "1"
  32. direc(path, int(howold))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement