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.
13 downloads_dir = os.path.join(os.environ["HOME"], "Downloads")
15 for f in os.listdir(downloads_dir):
16 p = os.path.join(downloads_dir, f)
18 if not os.path.isfile(p):
24 # Exclude partially downloaded files from Firefox
25 if f.endswith(".part"):
31if __name__ == "__main__":
32 print(max(get_downloads(), key=lambda p: os.stat(p).st_mtime))