简体   繁体   English

Winerror 183 文件已存在时无法创建文件

[英]Winerror 183 Cannot create a file when that file already exists

so i'm using shutil in python.所以我在python中使用shutil。 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).我想要做的是将一个目录从我的 onedrive 文件夹移动到我的 Adob​​e Premeiere 项目文件夹(包含目录中的内容)。 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'当我执行命令“shutil.copytree(src, des)”时,出现错误: [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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FileExistsError:[WinError 183] 当文件已存在时无法创建文件 - FileExistsError: [WinError 183] Cannot create a file when that file already exists 如何解决 FileExistsError: [WinError 183] 当文件已经存在时无法创建文件? - How to resolve FileExistsError: [WinError 183] Cannot create a file when that file already exists? 为什么我收到错误消息:“FileExistsError: [WinError 183] 当文件已存在时无法创建文件”? - Why am I getting the error: "FileExistsError: [WinError 183] Cannot create a file when that file already exists"? 重命名txt文件。 编辑版本:[错误183]该文件已存在时无法创建该文件 - Rename txt file. Edited version: [Error 183] Cannot create a file when that file already exists Python无法创建文件错误[错误:183] - Python Cannot create a file error [Error : 183] Google App Engine:“文件已经存在时无法创建” - Google App Engine: “Cannot create a file when that file already exists” Python 创建目录错误 当文件已存在时无法创建文件 - Python create directory error Cannot create a file when that file already exists 使用Python观察到该文件已存在时无法创建文件 - Cannot create a file when that file already exists error observed using Python python os.rename“”在该文件已存在时无法创建该文件 - python os.rename “”cannot create a file when that file already exists os.rename 无法创建已存在的文件 - os.rename cannot create a file that already exists
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM