>> 4) look for the latest file in the directory /a/b/c/d/test/123456/789 > > Slightly more complex, you need the creation timestamp. > You can find that with os.path.getctime() (or several > other options, eg os.stat) here's a trick you might be able to make use of: somelist = generate-list-of-files-in-directory newest = max(somelist, key=os.path.getctime)