{"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":"python","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,"search_vec":"'1.2.0':34 'accuraci':49 'activ':40 'address':46 'bug':47 'cadenc':42 'creation':3,18,58 'ctime':20,60 'current':30 'design':14 'directori':24 'featur':53 'file':2,22,55 'fix':48 'improv':50 'infrequ':38 'metadata':57 'new':52 'oper':27 'python':12 'releas':41 'set':16 'setctim':8 'setter':5 'small':11 'system':28,56 'time':4,19,59 'typic':45 'updat':44 'util':13 'version':33 'win32':7 'win32-setctime':6 'window':1,26,54","created_at":"2026-04-09T04:03:06.604287+00:00","updated_at":"2026-04-17T00:41:49.522784+00:00","problems":[{"fix":"Update the `win32-setctime` package to its latest version using `pip install --upgrade win32-setctime`.","cause":"This error occurs when the installed `win32-setctime` library is outdated or incompatible with the underlying `pywin32` version, leading to an incorrect internal call for setting file times.","error":"AttributeError: module 'win32file' has no attribute 'SetFileTime'"},{"fix":"Run the Python script with administrator privileges, ensure no other applications are holding a lock on the file, or verify that the current user has sufficient write permissions to the target path.","cause":"The Python process lacks the necessary operating system permissions to modify the creation time of the specified file or directory, often due to administrator privileges, file locks, or restricted user rights.","error":"PermissionError: [WinError 5] Access is denied"},{"fix":"Install the package using `pip install win32-setctime`, and ensure your code uses `import setctime`.","cause":"The `win32-setctime` package has not been installed in the current Python environment, or the import statement incorrectly uses a different name than the module's actual name.","error":"ModuleNotFoundError: No module named 'setctime'"},{"fix":"Ensure you are running the script on a Windows operating system where `pywin32` can be installed (which is typically handled as a dependency when `win32-setctime` is installed). If on a non-Windows OS, `win32-setctime` cannot be used.","cause":"The `win32-setctime` library relies on the Windows-specific `pywin32` package; this error occurs if `pywin32` is not installed or if the code is being executed on a non-Windows operating system.","error":"ImportError: No module named 'win32file'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Delgan/win32-setctime","docs":null,"changelog":null,"pypi":"https://pypi.org/project/win32-setctime/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}