I have cobbled together this code which gives me regex matches of files whose names either begin with either YYYYMMDD_? or erased_YYMMDD_? and whose extensions are exml or ewav. Now I need to compare the date string (regex match) in the filename to today's date. If the result of the comparison results in YYYMMDD being older than 180 days, I should print something to indicate this. If not, nothing need be done. Should I write another function to compare each matched regex to today's date or is that overkill? Thanks.
todaystring = date.today().strftime("%Y%m%d") oldest = date.today() - timedelta(days=180) def get_files(extensions): all_files = [] for ext in extensions: all_files.extend(Path('/Users/msh/Python/calls').glob(ext)) return all_files for file in get_files(('*.ewav', '*.exml')): print(re.match("[0-9]{8}|erased_",file.name)) -- The plural of anecdote is not "data." _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor