Setting file creation date

Will Stuyvesant hwlgw at hotmail.com
Fri Oct 18 12:49:03 EDT 2002


'''
Usage:
C:> python newdate.py <filename> <ddmmyyyy>
Guess what happens!
'''

import os
import sys
import time

newdate = sys.argv[2]
d = int(newdate[2:4])
m = int(newdate[:2])
y = int(newdate[4:])
# 12 hours, 1 minute: gives 01:01 PM, odd
t = time.mktime((y, d, m, 12, 1, 0, 0, 0, 0))
os.utime(sys.argv[1], (t, t))


'''
Works like a charm here with Windows XP.  People had problems getting
this functionality in a thread on c.l.p. in 2001.  So maybe this does
not work with Windows NT or 2000.


QOTD

If you don't have the time right now,
will you have redo right time later?
'''



More information about the Python-list mailing list