How to change a file's date/timestamp?

Peter Hansen peter at
Fri Aug 20 13:07:18 CEST 2004

pythos wrote:

> How do you change a file's last-modified date and timestamp in Python?

     utime(path, (atime, utime))
     utime(path, None)

     Set the access and modified time of the file to the given values.
     If the second form is used, set the access and modified times to the
     current time.

This and many other functions are in the 'os' standard module, one
of the few very very widely used and useful modules... you should
read the online docs for it, along with "sys", and "time" at least,
before doing any more coding. ;-)


More information about the Python-list mailing list