Template request | Bug report | Generate Data Product
Tags: #python #os #library #file #modified #directory
Author: Florent Ravenel
Description: This notebook will show how to get the last file modified from a directory using the os library.
References:
import os
# Set the directory path
directory_path = "./"
# Get the list of files in the directory
files_list = os.listdir(directory_path)
# Get the last file modified
last_file_modified = max(files_list, key=os.path.getmtime)
# Print the last file modified
print(f"The last file modified is {last_file_modified}")