This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: shutil-copytree: Create dst folder only if it doesn't exist
Type: behavior Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder: add exist_ok to shutil.copytree
View: 20849
Assigned To: Nosy List: rst0py, takluyver
Priority: normal Keywords:

Created on 2017-12-07 20:56 by rst0py, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4751 closed rst0py, 2017-12-07 20:56
Messages (2)
msg307823 - (view) Author: Radostin (rst0py) Date: 2017-12-07 20:56
shutil.copytree method always tries to create the destination directory which raises the error message "OSError: [Errno 17] File exists".

This issue has been discussed here:
https://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth
msg307845 - (view) Author: Thomas Kluyver (takluyver) * Date: 2017-12-08 10:46
This is documented:

>  The destination directory, named by dst, must not already exist

https://docs.python.org/3/library/shutil.html#shutil.copytree

I guess that avoids complications that might arise from merging a directory.
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76428
2017-12-09 03:47:52martin.pantersetsuperseder: add exist_ok to shutil.copytree
2017-12-08 10:51:19rst0pysetstatus: open -> closed
resolution: not a bug
stage: resolved
2017-12-08 10:46:27takluyversetnosy: + takluyver
messages: + msg307845
2017-12-07 20:56:56rst0pycreate