Here is a python script that will copy files and directories from one folder to another:
import os
import shutil
# source directory
src = '/path/to/source/folder'
# destination directory
dst = '/path/to/destination/folder'
# copy files and directories
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d)
else:
shutil.copy2(s, d)
This script will recursively copy all files and directories from the source directory to the destination directory. It uses the shutil
module’s copytree()
and copy2()
functions to copy directories and files, respectively.
Note that this script will not handle errors, such as if the destination directory does not exist or if the user does not have permission to write to the destination directory. You may want to add error handling to the script to handle these cases.