Setting file creation date

Roman Suzi rnd at onego.ru
Fri Aug 10 10:36:54 EDT 2001


On Fri, 10 Aug 2001, Alex Martelli wrote:

>"Fredrik Seehusen" <fse at npt.no> wrote in message
>news:e77b4645.0108100226.4cfaf671 at posting.google.com...
>> 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 :(
>
>os.utime lets you set the accessed and modified dates, but I
>don't think NT lets you change creation-date -- you'd have to
>change your computer's date, create a new file copying the
>old one, etc, etc, I suspect.

Sorry for my total ignorance of NT, but AFAIK UNIX/Linux do not
have file creation date stored:

st = os.stat(file)
print "last access", ctime(st[stat.ST_ATIME])
print "last modification", ctime(st[stat.ST_MTIME])
print "last status change", ctime(st[stat.ST_CTIME])

- is all you get there. First one record when file was accessed
last time (this feature could be switched off on some filesystems
to have better performance), mtime is file _contents_
modification time and ctime is file status information
modification time.

(I long time thought ctime is about creation time, but
then understood I was wrong.)

Also I remember, Macintosh had file creation time stored,
but Windows 9x store only two times (probably mtime and ctime).

atime and mtime are quite easy to change, and the nature
of ctime is more subtle.

So, I wonder where creation date is used and how it survives
archiving...

>Alex

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Friday, August 10, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "This mind intentionally left blank." _/





More information about the Python-list mailing list