[Tutor] deleting files that are older than x days old
Mike Hansen
mhansen at cso.atmel.com
Wed Jul 13 18:54:31 CEST 2005
From a python program, I want to delete certain files that are older than x
days old.
To get the time that the file was last modified, it looks like I need to use
os.path.getmtime(path). This gives you the time represented in the number of
seconds from the epoch.
I'd like to convert this into a datetime object, but I can't seem to figure out
how. Once it's a datetime object, I can do simple (datetime.datetime.today() -
filedatetime).days to figure out the days old.
How do you convert a time represented in seconds from the epoch into a datetime
object?
Mike
More information about the Tutor
mailing list