zut.files.copytree

zut.files.copytree(src: str | Path, dst: str | Path, symlinks: bool = False, ignore: Callable[[str, list[str]], list[str]] = None, ignore_dangling_symlinks: bool = False, dirs_exist_ok: bool = False)

Recursively copy a directory tree rooted at src to a directory named dst and return the destination directory.

Permissions and times of directories are copied with copystat(), individual files are copied using copy2().

If symlinks is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. If the file pointed by the symlink doesn’t exist, an exception will be added. You can set ignore_dangling_symlinks to true if you want to silence this exception. Notice that this has no effect on platforms that don’t support os.symlink.

If dirs_exist_ok is false (the default) and dst already exists, an error is raised. If dirs_exist_ok is true, the copying operation will continue if it encounters existing directories, and files within the dst tree will be overwritten by corresponding files from the src tree.

If ignore is given, it must be a callable of the form ignore(src, names) -> ignored_names. It will be called recursively and will receive as its arguments the directory being visited (src) and a list of its content (names). It must return a subset of the items of names that must be ignored in the copy process.