How do I change the file creation date of a Windows file from Python?
You can modify the date created by copying a file. The file's created date becomes the modified date and the current date (when the file is copied) becomes the created date. You can copy a file on your PC to check.
You can manually change the Last Modified Date/Time for a file using a free software called Attribute Changer from http://www.petges.lu/. You will need to remember the modified date/time of your presentation file, modify the file and then use Attribute Changer to set the modified date/time to the previous one.
If you ever want to quickly update the Modified time stamp of a file to the current day and time, right-click that file, select Properties, select the TimeStamps tab, and then click the Touch button. That will instantly change the Last modified entry to the current day and time.
Yak shaving for the win.
import pywintypes, win32file, win32con def changeFileCreationTime(fname, newtime): wintime = pywintypes.Time(newtime) winfile = win32file.CreateFile( fname, win32con.GENERIC_WRITE, win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE | win32con.FILE_SHARE_DELETE, None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None) win32file.SetFileTime(winfile, wintime, None, None) winfile.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With