Hi Alec Thanks for your help. I want to change the creation timestamp. the code that you give is to change the modification and access time. I already find a solution using pywin32's win32file module
import win32file filehandle = win32file.CreateFile(file_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, 0, 0) win32file.SetFileTime(filehandle, ctime, atime, mtime) Regards, Liu Zhenhai 2011/11/25 Alec Taylor <alec.tayl...@gmail.com> > import os > import time > from stat import * > > #returns a list of all the files on the current directory > files = os.listdir('.') > > for f in files: > #my folder has some jpegs and raw images > if f.lower().endswith('jpg') or f.lower().endswith('crw'): > st = os.stat(f) > atime = st[ST_ATIME] #access time > mtime = st[ST_MTIME] #modification time > > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) > > On Fri, Nov 25, 2011 at 11:47 PM, 刘振海 <1989l...@gmail.com> wrote: > > Hi, > > I want to change the file creation timestamp using python, but I can not > > find a solution to do it. > > I know the way to change the file creation timestamp in C under Windows, > but > > I want to change it using python. > > I really need help! > > > > Regards, > > Liu Zhenhai > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > >
-- http://mail.python.org/mailman/listinfo/python-list