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.
 
 

26 lines
906 B

import os
import os.path as osp
import datetime
from util import no_parents
from util import get_drives
def build(after,*starts):
if isinstance(after,datetime.datetime):
after = after.timestamp()
var_unsubbed = map(osp.expandvars,starts)
abs_paths = map(osp.abspath,var_unsubbed)
starts = list(no_parents(abs_paths))
ret = []
for path in starts:
for root,dirs,files in os.walk(path,topdown=True):
try:
dirs[:] = list(filter(
lambda p: osp.getmtime(osp.join(root,p)) > after,
dirs
))
ret += [osp.join(root,file) for file in files]
except:
print('Error',root,sep= ': ')
return ret
if __name__ == "__main__":
td = datetime.datetime.today()
ret = build(datetime.datetime(td.year,(td.month - 1 -1)%12+1,1),r'X:\Users\Ralphie')