Jun-16-2021, 11:01 PM
With the following code, i made a
created_yesterday_stat_matcher
function, you could make different functions to match different stats.import datetime from pathlib import Path def created_yesterday_stat_matcher(path_stat): ctime = datetime.date.fromtimestamp(path_stat.st_ctime) return ctime == datetime.date.today() - datetime.timedelta(days=1) def directory_stat_matcher_files(directory, stat_matcher): for path in Path(directory).iterdir(): if stat_matcher(path.stat()): yield path directory = 'your directory' for path in directory_stat_matcher_files(directory, created_yesterday_stat_matcher): print(path)