Keep The Creation aka Birth Timestamp When Copying A File On A Mac In Python
NOTE : I'm not sure this is accurate. It looked like it when I first tested it, but I'm not sure now.
Leaving here until I can investigate further.
This is how you can make a copy of a file and maintain its "birth" time.
Note : I'm pretty sure you need XCode to get the [TODO: Code shorthand span ] command.
NOTE :
# this is the command to get the birth time of the inode
stat -f "%B" file_name
# and this is for the file modified time:
stat -f "%m" file_name
TODO : Formatting
# TODO: Add error handling in all this
=
=
=
# TODO: Make a better response
Notes :
- copy2 copies the most metadata of the possible python options, but still doesn't do the birth time. - [TODO: Code shorthand span ] doesn't copy it either. - TODO : show examples from [TODO: Code shorthand span ] command - TODO : put in details about the four times available for files.
links :
- https : //apple.stackexchange.com/a/99599/7828 - https : //stackoverflow.com/a/56009590/102401
TODO : Look at adding an answer to this one :
https : //stackoverflow.com/questions/56008797/how - to - change - the - creation - date - of - file - using - python - on - a - mac
TODO : Look at this answer and see if there's something in that pathlib that can be used for finding the data instead of using [TODO: Code shorthand span ] - https : //stackoverflow.com/a/52858040/102401
TODO : Look at [TODO: Code shorthand span ] to see what it perserves. According to the comment on this answer (https : //stackoverflow.com/a/17685271/102401) that's what copy2 is supposed to do. Check it with [TODO: Code shorthand span ] and see if it keeps the birth timestamp.