Registry / devops / win32-setctime

win32-setctime

JSON →
library1.2.0pypypi✓ verified 29d ago

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.

pip install win32-setctime
INSTALL
IMPORT
SIG · WIN32-SETCTIME
W
win32-setctime
devopspythonv1.2.0
Install
1.5s avg
Import
27ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.022s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.032s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setctime
✓ from win32_setctime import setctime

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).

import os import time from datetime import datetime from win32_setctime import setctime # Create a dummy file file_path = 'my_test_file.txt' with open(file_path, 'w') as f: f.write('Hello, world!') # Get current timestamp current_timestamp = time.time() print(f"Current file creation time: {datetime.fromtimestamp(os.path.getctime(file_path))}") # Set a new creation time (e.g., 1 day in the past) new_timestamp = current_timestamp - (24 * 60 * 60) setctime(file_path, new_timestamp) print(f"New file creation time: {datetime.fromtimestamp(os.path.getctime(file_path))}") # Clean up os.remove(file_path)
Debug
Known issues
gotchaThis 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.
fix
Ensure your code path for `setctime` is only executed on Windows, typically by checking `sys.platform == 'win32'`.
affects: all
gotchaBefore 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.
fix
Upgrade to version 1.0.4 or higher to ensure accurate timestamp conversion for all valid values.
affects: <1.0.4
gotchaThe `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`.
fix
To prevent following symlinks, call `setctime(path, timestamp, follow_symlinks=False)`.
affects: all
gotchaPrior 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.
fix
Upgrade to version 1.0.3 or higher to gain support for setting the creation time of directories.
affects: <1.0.3
Errors
Common errors & fixes
AttributeError: module 'win32file' has no attribute 'SetFileTime'
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.
fix
Update the `win32-setctime` package to its latest version using `pip install --upgrade win32-setctime`.
PermissionError: [WinError 5] Access is denied
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.
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.
ModuleNotFoundError: No module named 'setctime'
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.
fix
Install the package using `pip install win32-setctime`, and ensure your code uses `import setctime`.
ImportError: No module named 'win32file'
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.
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.
Upgrade
Version history
1.2.0latest on PyPI · released Dec 7, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
32
OpenAI (training)
1
Resources
win32-setctime — pip install win32-setctime · libregistry