{"id":1787,"library":"win32-setctime","title":"Windows File Creation Time Setter","description":"win32-setctime is a small Python utility designed to set the creation time (ctime) of files and directories on Windows operating systems. It currently is at version 1.2.0 and has an infrequent, but active, release cadence, with updates typically addressing bug fixes, accuracy improvements, or new features.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/Delgan/win32-setctime","tags":["windows","file system","metadata","creation time","ctime"],"install":[{"cmd":"pip install win32-setctime","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"symbol":"setctime","correct":"from win32_setctime import setctime"}],"quickstart":{"code":"import os\nimport time\nfrom datetime import datetime\nfrom win32_setctime import setctime\n\n# Create a dummy file\nfile_path = 'my_test_file.txt'\nwith open(file_path, 'w') as f:\n    f.write('Hello, world!')\n\n# Get current timestamp\ncurrent_timestamp = time.time()\nprint(f\"Current file creation time: {datetime.fromtimestamp(os.path.getctime(file_path))}\")\n\n# Set a new creation time (e.g., 1 day in the past)\nnew_timestamp = current_timestamp - (24 * 60 * 60)\nsetctime(file_path, new_timestamp)\n\nprint(f\"New file creation time: {datetime.fromtimestamp(os.path.getctime(file_path))}\")\n\n# Clean up\nos.remove(file_path)\n","lang":"python","description":"This quickstart demonstrates how to create a file, then use `setctime` to modify its creation timestamp to a specific point in time (in this case, one day in the past)."},"warnings":[{"fix":"Ensure your code path for `setctime` is only executed on Windows, typically by checking `sys.platform == 'win32'`.","message":"This library is strictly for Windows operating systems. Attempting to use `win32-setctime` on non-Windows platforms will result in errors, as it relies on Windows-specific kernel32 DLL calls.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to version 1.0.4 or higher to ensure accurate timestamp conversion for all valid values.","message":"Before version 1.0.4, `setctime` could have accuracy issues when converting very large or very small timestamps, leading to slight inaccuracies in the set creation time.","severity":"gotcha","affected_versions":"<1.0.4"},{"fix":"To prevent following symlinks, call `setctime(path, timestamp, follow_symlinks=False)`.","message":"The `setctime` function, by default, follows symbolic links. If you need to set the creation time of the symbolic link itself rather than its target, you must explicitly pass `follow_symlinks=False`.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to version 1.0.3 or higher to gain support for setting the creation time of directories.","message":"Prior to version 1.0.3, `setctime` did not support changing the creation time of directories. Attempts to use it on a directory would likely fail.","severity":"gotcha","affected_versions":"<1.0.3"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}