The shutil
module offers a number of high-level operations on files and collections of files. It provides functions for copying files, directories, and even entire directory trees.
shutil.copy()
: Copies a file.shutil.copy2()
: Copies a file, preserving metadata.shutil.copytree()
: Recursively copies an entire directory tree.shutil.move()
: Recursively moves a file or directory to another location.shutil.rmtree()
: Recursively deletes a directory tree. Use with caution!shutil.disk_usage()
: Get disk usage statistics.shutil.make_archive()
: Create an archive file (e.g., zip, tar).shutil.unpack_archive()
: Unpack an archive file.See the official Python documentation for more details.