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.
The destination needs to be the name of the directory to be created, not the parent directory that it will be created in. So you need:
des = r"D:/PROJECTS/ADOBE_PREMIERE/" + i