On Sat, 26 Nov 2011 00:51:34 +1100, Alec Taylor wrote: > 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
The original poster asks for how to change the file creation timestamp. (The poster assumes that there is a creation timestamp, which is not necessarily the case -- many file systems do not store the creation time.) > new_mtime = mtime + (4*3600) #new modification time > > #modify the file timestamp > os.utime(f,(atime,new_mtime)) Note that this is from the posix module, so it probably won't work under Windows. > > 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