Advertisement
Danila_lipatov

get_last_file_function

Feb 6th, 2025
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. def get_latest_file(directory):
  2.     files = [os.path.join(directory, f) for f in os.listdir(directory)]
  3.     files = [f for f in files if os.path.isfile(f)]
  4.     latest_file = max(files, key=os.path.getctime)
  5.     return latest_file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement