python get latest edited file from any directory

Solutions on MaxInterview for python get latest edited file from any directory by the best coders in the world

showing results for - "python get latest edited file from any directory"
Philipp
07 Jun 2016
1from os.path import expanduser
2import os
3home = expanduser("~")
4latest_edited_folder = max([f for f in os.scandir(home)], key=lambda x: x.stat().st_mtime).name
5search_on = home+'\\'+latest_edited_folder
6latest_edited_file = max([f for f in os.scandir(search_on)], key=lambda x: x.stat().st_mtime).name