0

When I am using shutil, I get an unexpected error:

System error 183. Cannot create file when that file already exists

I am using this:

shutil.copytree(src,dst)

src,dst are paths to my directories which I would like to copy. Names are different. For example:

src = 'D:\test\tmp\dir1'
dst = 'D:\test\tmp\dir2'

I know, I could delete dir2 and everything is ok, but I would like to do it without this, is it possible with shutil ?

galath
  • 5,717
  • 10
  • 29
  • 41
  • 1
    possible duplicate of [How to copy directory recursively in python and overwrite all?](http://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all) – Barmar Jul 26 '15 at 12:55

2 Answers2

0

The document for shutil specifically says that the destination directory must not exist. This happens because it makes a os.makedirs(dst). If you want to append files it could be useful if you used shutil.copyfile.

-1

I am not sure if using shuthil is possible here. Perhaps you can save as a new file?