1

I want to move a file and I'm having the following bug:

Traceback (most recent call last):
File "G:\Programming\Hack\scripts\# cut file.py", line 4, in <module>
shutil.move(src, dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 316, in move
copy2(src, real_dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 144, in copy2
copyfile(src, dst)
File "C:\Program Files 1\Python2\lib\shutil.py", line 97, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'E:\\windows.information.exe'

my script:

import shutil
src = "C:\\Users\\Michael\\Desktop\\windows.information.exe"
dst = "E:\\"
shutil.move(src, dst)

My main problem:

IOError: [Errno 13] Permission denied: 'E:\\windows.information.exe
  • Try using shutil.copy() instead https://docs.python.org/2/library/shutil.html#shutil.copy – diegoiva Apr 26 '18 at 20:59
  • If your file is an exe, try to close the program it runs before copying. – OSA413 Apr 26 '18 at 21:05
  • Possible dupe https://stackoverflow.com/questions/10575750/python-ioerror-errno-13-permission-denied – Jorjon Apr 27 '18 at 03:00
  • Possible duplicate of [Python - IOError: \[Errno 13\] Permission denied:](https://stackoverflow.com/questions/10575750/python-ioerror-errno-13-permission-denied) – Jorjon Apr 27 '18 at 03:00

3 Answers3

0

The log shows you do not have proper permissions to access the file. try changing the permissions first

mad_
  • 8,121
  • 2
  • 25
  • 40
0

You should take a look at shutil.copy(), since shutil move looks for a file and E: it's a directory and not a file.

import shutil
src = "C:\\Users\\Michael\\Desktop\\windows.information.exe"
dst = "E:\\"
shutil.copy(src, dst)
diegoiva
  • 454
  • 1
  • 8
  • 17
0

in fact,this error occurred by permission. in c://Users ,need adminster authority to do it . you should use shutil.copy(src,dst) copy file and authority

mino
  • 36
  • 5