I currently have a statement that says:
import glob
push_directory = 'Risk_Summary'
current_dir = os.getcwd() + '/Reports/' + push_directory + '/Saved_PDF/*'
list_of_files = glob.glob(current_dir)
latest_file = max(list_of_files, key=os.path.getctime)
file_name = os.path.basename(latest_file)
date_created = datetime.fromtimestamp(os.path.getctime(latest_file))
if date_created.day == datetime.now().day:
risk_summary_report(latest_file, file_name, push_directory)
else:
pass
The problem with using date created is the fact that it relies on the time someone created the file.
Here I have 2 options
- Accept a range of dates
- Figure how to get 'date accessed' which would result in the day it was saved.
How can I change my logic to either accept a week range of dates, or (preferably) how can I get the date of access?
I found this link: Python get last reading time of a file
Having trouble figuring out how to implement it in my code. Thank you very much!