This post was for 08.02.2022
In Python, I usually retrieve ctime
(means creation time for me) of a file using the following code:
from pathlib import Path
f = Path(file_path). # file_path is the path to any files in your system
file_stat = f.stat()
print(file_stat.st_ctime)
BUT,
I've got troubles when relying on this approach, because:
ctime()
does not refer to creation time on *nix systems, but rather the last time the inode data changed.
I found this from this answer: https://stackoverflow.com/a/237084/6563277
The reason is that I have modified ctime by doing something to the inode: chmod
and chown
on the file.
Top comments (0)