Setting file creation date

Hans Nowak hnowak at cuci.nl
Fri Aug 10 07:32:03 EDT 2001


>===== Original Message From fse at npt.no (Fredrik Seehusen) =====
>Hello,
>
>How do I set the creation date when opening a file, or override the
>creation date of a given file (... if it is possible in python)?
>
>This has to be done in Windows NT by the way :(

Hmm, os.utime does more or less what you want:

>>> print os.utime.__doc__
utime(path, (atime, utime)) -> None
utime(path, None) -> 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.
>>>
>>> import os, time
>>> t = time.mktime((1973, 9, 2, 16, 5, 0, 0, 0, 0))
>>> os.utime("c:/test.txt", (t, t))

On my box (NT4/SP6/Py2.1) this doesn't seem to set the *creation* date/time, 
but rather the *modified* date/time. Hmm.

HTH,

--Hans Nowak





More information about the Python-list mailing list