python get newest file in directory
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)
python get newest file in directory
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)
python get latest edited file from any directory
from os.path import expanduser
import os
home = expanduser("~")
latest_edited_folder = max([f for f in os.scandir(home)], key=lambda x: x.stat().st_mtime).name
search_on = home+'\'+latest_edited_folder
latest_edited_file = max([f for f in os.scandir(search_on)], key=lambda x: x.stat().st_mtime).name
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us