I have a folder that csv files are stored in. How can I get python to search this folder and return the filename of the most recent file created. e.g search C:\CSVfiles and return filename in the form of C:\CSVfiles\CSVmostrecent.csv? I’m using windows.
Share
You can use the
keyparameter to themax()function:Depending on your intention, you might want to use
os.path.getctimeinstead ofos.path.getmtime.