简体   繁体   中英

Winerror 183 Cannot create a file when that file already exists

so i'm using shutil in python. What I want to do is move a directory from my onedrive folder, to my Adobe Premeiere projects folder (with the content in the dir). When i perform the command "shutil.copytree(src, des)" I get the error: [Winerror 183] Cannot create a file when that file already exists: 'C:/source'

There are no folder/file that matches with the tree that I'm copying at the source.

Here is my code:

import os
import shutil

os.chdir("C:/Users/carlh/OneDrive/Gaffla's videor")

video = input("Enter number: ")

def myfunc():
    for i in os.listdir():
        episod = str(i).split('#')
        if episod[1] == video:
            print("Success")
            print(i)
            src = r"C:/Users/carlh/OneDrive/Gaffla's videor/" + i
            des = r"D:/PROJECTS/ADOBE_PREMIERE"
            shutil.copytree(src, des)


myfunc()

Is there a bug in my code or is there mistake in the explorer? Please help me to make this work. Thanks.

目的地需要是要创建的目录的名称,而不是将在其中创建的父目录。所以你需要:

des = r"D:/PROJECTS/ADOBE_PREMIERE/" + i

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM