You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
906 B

  1. import os
  2. import os.path as osp
  3. import datetime
  4. from util import no_parents
  5. from util import get_drives
  6. def build(after,*starts):
  7. if isinstance(after,datetime.datetime):
  8. after = after.timestamp()
  9. var_unsubbed = map(osp.expandvars,starts)
  10. abs_paths = map(osp.abspath,var_unsubbed)
  11. starts = list(no_parents(abs_paths))
  12. ret = []
  13. for path in starts:
  14. for root,dirs,files in os.walk(path,topdown=True):
  15. try:
  16. dirs[:] = list(filter(
  17. lambda p: osp.getmtime(osp.join(root,p)) > after,
  18. dirs
  19. ))
  20. ret += [osp.join(root,file) for file in files]
  21. except:
  22. print('Error',root,sep= ': ')
  23. return ret
  24. if __name__ == "__main__":
  25. td = datetime.datetime.today()
  26. ret = build(datetime.datetime(td.year,(td.month - 1 -1)%12+1,1),r'X:\Users\Ralphie')