Comparing file last access date

kaklis at gmail.com kaklis at gmail.com
Sun Feb 14 12:59:12 EST 2010


Hi to all,
what i want is to search a folder, and if the last access date of the
files in that folder is greater than, lets say 7 days, those files
deleted. (Somekind of a file cleaner script)
I had problems with converting

now = today = datetime.date.today()
and
stats = os.stat(file)
lastAccessDate = time.localtime(stats[7])

into matching formats so that
     if (now - lastAccessDate) > 7:
                 delete the file

what i do wrong
Thanks in advance
Antonis



More information about the Python-list mailing list