How to change a file's date/timestamp?

Peter Hansen peter at engcorp.com
Fri Aug 20 07:07:18 EDT 2004


pythos wrote:

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

utime(...)
     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. ;-)

-Peter



More information about the Python-list mailing list