I have some python code using shutil.copyfile:
import os
import shutil
src='C:\Documents and Settings\user\Desktop\FilesPy'
des='C:\Documents and Settings\user\Desktop\\tryPy\Output'
x=os.listdir(src)
a=os.path.join(src,x[1])
shutil.copyfile(a,des)
print a
It gives me an error:
IOError: [Errno 13] Permission denied: 'C:\\Documents and Settings\\user\\Desktop\\tryPy\\Output'
Why don't I have permission to copy the file?
I advice you rather use shutil.copyfile rather than shutil.copy if you can.
With shutil.copyfile, you have to consider metadata such as writing permission.
From the documentation of
shutil.copyfile
:So I guess you need to either use
shutil.copy
or add the file name todes
: