Reputation: 350
I'm trying to use the shutil module in python. I want to copy a folder('movee'
) from my cwd to the 'D'
drive.
Here's the code:
import shutil
shutil.copytree('movee', 'D:\\')
But when i run it i get the following error:
PermissionError: [WinError 5] Access is denied: 'D:\\'
I tried running cmd as an administrator but the problem persisted. Can someone help me fix this?
Upvotes: 1
Views: 213
Reputation: 33704
The destination directory must not exist and is named in the destination argument for copytree
. (Other copy tools behave differently and use the basename of the source as the destination if the destination is a directory.) This should work:
shutil.copytree('movee', 'D:\\movee')
The error is probably a consequence of an attempt to create the directory D:\
.
Upvotes: 2