Accessing the files by last modified time

Peter Otten __peter__ at web.de
Thu Mar 22 08:38:00 EDT 2012


Sangeet wrote:

> I've been trying to write a script that would access the last modified
> file in one of my directories. I'm using Win XP.

import os
import glob

path = r"c:\one\of\my directories\*"

youngest_file = max(glob.glob(path), key=os.path.getmtime)




More information about the Python-list mailing list