Copy directory contents into a directory with python [duplicate]

I found this code working which is part of the standard library: from distutils.dir_util import copy_tree # copy subdirectory example from_directory = “/a/b/c” to_directory = “/x/y/z” copy_tree(from_directory, to_directory) Reference: Python 2: https://docs.python.org/2/distutils/apiref.html#distutils.dir_util.copy_tree Python 3: https://docs.python.org/3/distutils/apiref.html#distutils.dir_util.copy_tree

shutil.rmtree fails on Windows with ‘Access is denied’ [duplicate]

Check this question out: What user do python scripts run as in windows? Apparently the answer is to change the file/folder to not be read-only and then remove it. Here’s onerror() handler from pathutils.py mentioned by @Sridhar Ratnakumar in comments: def onerror(func, path, exc_info): “”” Error handler for “shutil.rmtree“. If the error is due to … Read more