3This script prints the path to the newest file in my Downloads folder.
5I use it when I've downloaded a file in my web browser, and I want
6to use that file immediately without checking what its filename is.
14 downloads_dir = os.path.join(os.environ["HOME"], "Downloads")
16 for f in os.listdir(downloads_dir):
17 p = os.path.join(downloads_dir, f)
19 if not os.path.isfile(p):
28def downloaded_time(p):
29 return os.stat(p).st_mtime
32if __name__ == "__main__":
33 print(max(get_downloads(), key=lambda p: downloaded_time(p)))