Answers for "copy director structure python"

2

python copy dir

from shutil import copytree
shutil.copytree("sourcedir", "destination")
Posted by: Guest on February-26-2021
0

copy director structure python

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)
Posted by: Guest on April-14-2022

Code answers related to "copy director structure python"

Python Answers by Framework

Browse Popular Code Answers by Language