How to access file last modified dates on each file in a directory

Jia Lu Roka100 at gmail.com
Sun Oct 29 23:26:41 EST 2006


RAMohrmann at adelphia.net wrote:
> Greetings,
>
> I am attempting to view all files in a directory and if those files
> have not been modified within the last couple days I will remove them.
> In order to do this I need to look at the file date modied and check
> the date. I know how to look at each file name and I know how to remove
> the file. I just can't figure out how to get access to the date last
> modifed filed.

For this you have some solutions.

1,
import os
import time
time.ctime(os.stat(r"L:\MyDoc\EBook\Python").st_mtime)

2,
os.path.getmtime()

3, in Win32
win32file.GetFileTime
int = GetFileTime(handle, creationTime , accessTime , writeTime )




More information about the Python-list mailing list