Topic starter 09/12/2021 5:11 pm
I need to get the latest file of a folder using python.
Topic starter 09/12/2021 5:13 pm
Use the following code. Make sure you change below '/path/to/folder/*' with your required path.
import glob import os list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv latest_file = max(list_of_files, key=os.path.getctime) print(latest_file)