The way to copy a directory/folder and its subdirectories/subfolders in Python is to use shutil.copytree(). Documentation states that this function uses shutil.copy2()
to copy files:
Permissions and times of directories are copied with copystat(), individual files are copied using copy2().
Furthermore, there is a HUGE RED WARNING at the start of this documentation stating:
Warning Even the higher-level file copying functions (shutil.copy(),
shutil.copy2()) cannot copy all file metadata. On POSIX platforms,
this means that file owner and group are lost as well as ACLs. On Mac
OS, the resource fork and other metadata are not used. This means that
resources will be lost and file type and creator codes will not be
correct. On Windows, file owners, ACLs and alternate data streams are
not copied.
Would I be correct to say that the outcome of:
shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False, dirs_exist_ok=False)
is different from the Linux command
cp -r src dst
If yes, then what is the remedy?
Sidebar: What does ACL mean? It is used in the documentation warning.