get last file in directory python

Solutions on MaxInterview for get last file in directory python by the best coders in the world

showing results for - "get last file in directory python"
Johanna
25 Feb 2019
1import glob
2import os
3
4list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
5latest_file = max(list_of_files, key=os.path.getmtime)
6print(latest_file)
7