xxxxxxxxxx
from shutil import copytree
shutil.copytree("sourcedir", "destination")
xxxxxxxxxx
import shutil
# if the meta data is important
shutil.copy2(source, destination)
#if the meta data is not necessarily needed
shutil.copy(source, destination)
xxxxxxxxxx
import shutil
def copytree(src, dst, symlinks=False, ignore=None):
if not os.path.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
copytree(s, d, symlinks, ignore)
else:
if not os.path.exists(d):
shutil.copy2(s, d)
copytree(source, destination)