1

I want to select a folder and then copy it and paste it somewhere, I did this with the tkinter and shutil module in Python.

Code:

from tkinter import filedialog
from tkinter import *
import shutil

window = Tk()
window.title("copyfolder")
window.geometry("210x50")

folderPath = StringVar()
def select_folder():
    folder_selected = filedialog.askdirectory()
    folderPath.set(folder_selected)
    folder = folderPath.get()
    shutil.copy2(folder, "/data")
    print("Complate")

Button(window,text="select",command=select_folder).place(x=80,y=10)

window.mainloop()

Error:

PermissionError: [Errno 13] Permission denied: 'C:/Users/name/Desktop/Myfolder'

1 Answers1

1

PermissionError: [Errno 13] Permission denied

As given by this link, this happens if you are trying to open a file, but your path is a folder.

As the comments state, use:

shutil.copytree()
chess_lover_6
  • 632
  • 8
  • 22