If you look at the documentation for shutil , you will immediately find the copy2 function, which:
copy() is copy2() , except that copy2() also tries to save all file metadata.
In recent versions of Python, there are many functions for executing bits and parts of this separately - copy , copymode , copystat , but if you just want to copy everything, copy2 makes everything possible.
As warns at the top of the documentation, “anything is possible” does not mean everything, but includes dates and other attributes. In particular:
On Windows, files, ACLs, and alternate data streams are not copied.
If you really need to include even this stuff, you will need to access the Win32 API (which is easiest to do with pywin32 ). But you do not.
abarnert
source share