python get newest file in directory

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

showing results for - "python get newest file in directory"
Domenico
09 Jul 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.getctime)
6print(latest_file)
7