Search code examples
pythonshutilfile-copying

`shutil.copyfile` Error: Permissions Denied


I have worked through a number of other threads on this, but not of their solutions seem to work here, that or I am not understanding properly, and would love your help.

I am getting a:

IOError: [Errno 13] Permission denied: 'W:\\test\\Temporary Folder 195\\Sub-fold1 

This is the general code i started with.

    summary_file = r'W:/test/SDC Analysis Summary.docm'
    shutil.copyfile(summary_file, os.getcwd())

I have also varied this a little bit based on other threads, specifically replacing summary_file with the actual text and also adding \ to the end of working directory without success. Really don't know what I'm missing here. I know that the Documentation is looking for complete paths, but I believe I am satisfying that requirement. What am I missing here?

Note: there is a desire to use copyfile over copy due to the speed increase.


Solution

  • From the documentation:

     dst must be the complete target file name
    

    You can't just use os.getcwd() as the destination.