0

I have looked at tons of posts and things for 1-2 hours now and i can't find a solution. Im trying to use shutil.copytree() however it makes the folder then throws the error "FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\background'"? And im not entirely sure why here is my program

import shutil
import ctypes
import random
import getpass
import os
username = str(getpass.getuser())
target_images_path = r"C:\Users\{}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\background".format(username)
if not os.path.exists(target_images_path):
    os.makedirs(target_images_path)
target_path = r"C:\Users\{}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup".format(username)
shutil.copy("main.exe", target_path)
shutil.copytree('background', target_images_path)
kom
  • 1
  • https://docs.python.org/3.8/library/shutil.html#shutil.copytree See the `dirs_exist_ok` argument – berardig Feb 05 '20 at 20:06
  • try [`this answer`](https://stackoverflow.com/a/12514470/3081283) from @atzz in another related question – Mike Mulhearn Feb 05 '20 at 20:11
  • Thanks mike, that sort of worked? like it copies the folder and things without a problem but the folder is epty for some reason – kom Feb 05 '20 at 22:37

0 Answers0