Python change file creation date


















Improve this question. Claudiu Claudiu k gold badges silver badges bronze badges. Sebastian: thanks for the links. David: hah nice, i'll remember that. Claudiu: I've posted it for readers who search google for "python change file date windows".

Your question is the second link. Same question for Linux: stackoverflow. Show 1 more comment. Active Oldest Votes. CreateFile fname, win32con. SetFileTime winfile, wintime, None, None winfile. Improve this answer. If you get an ImportError and wonder where you could find pywintypes as I did : sourceforge. Delta's solution is much simpler. I like this "yak shaving" indeed this feels like what I am trying to do to support the Wintendo operating system.

CreateFile fname, ntsecuritycon. Add a comment. CreateFileW filepath, , 0, None, 3, , None windll. SetFileTime handle, byref ctime , None, None windll. Delgan Delgan This code would be more useful if the meanings of the magic numbers were explained. My guesses are: - epoch is time in seconds? Since when? Maybe it doesn't matter?

This can sometimes be confused with creation time but these are very different. Creation time is normally held by the operating system and states when a file was created.

This means if you download a file from the internet, the creation time will change and be the time it was downloaded. Module os has numerous functions for manipulating directories and files.

Expand Select Wrap Line Numbers. Thank you very much :. Post Reply. Similar topics Python. FTP file creation date. NET Framework. File Creation Time. Get a file's version in PHP. Anyway to change the file create date? Catch Multiple Exceptions in One Line. Append to a File. Related Topics Python Get Current time. How to get current date and time in Python? Python timestamp to datetime and vice-versa.

Path 'abc. Share on:. Did you find this article helpful? Sorry about that.



0コメント

  • 1000 / 1000