I want to access a folder which is created automatically according to date like for today it will be created '20230222' for tomorrow it will be created as '20230223' in E drive .Inside every folder .txt files are created which I want to access,but I dont want to change the path everyday.I want to pick the latest folder which will be created according to date and access the .txt files inside them
I tried this:
import os
import glob
path='E:/20230222/*'
files_list=glob.glob(path)
latest_file=max(files_list,key=os.path.getctime)
print(latest_file)
This returns the latest .txt file which is created inside today's folder[20230222] But I want to set path in a way that it should directly select the folder whenever it is created according to that day's date, like for tomorrow it should directly select [20230223] Folder after it is formed in E drive