Error 5 : Acces is denied when moving files in python -


I am working on a program for a few days now, and I got stuck on an error last night. I have already seen other questions here but no one is working. I'm taking files from 1 drive to second place, and in the beginning it worked, but now it started to say this error:

Edit: Just seen that this fact transfers files, and then it gives me an error

  traceback (most recent call final): File "C: \ user \ DC \ Desktop \ prototype \ prototype ", line 9, & lt; Module & gt; Shutil.move (src, dst) file "c: \ Python27 \ lib \ shutil.py", line 300, in the rmtree (src) file "C: \ Python27 \ lib \ shutil.py" in line, rmtree (Error 5) Access denied: 'E:' (error: 5) rmtree os.rmdir (path) in line (ARMDR, path, sys.exc_info ()) "C: \ Python27 \ lib \ shutil.py", line 254   

And here's my code snippet. Import

E: or drive? : -)

If the E: drive is empty, check that if this is the case, then there is nothing to move if you want to transfer the files. Do not drive, use wildcards.

Hint: E: \ *. *

Update:

Simply open the code of linen 82 as an exception to open syscall:

> open (src, 'rb') as fsrc:

It looks like it is a Windows drive or a pattern like e: \ * *. * :

 Can not control  fo = open (R'D: \ *. * ',' Rb ') D: \> Python testopen.py tracebacks (most recent call final): file "testopen.py", line 2, & lt; Module & gt; IORR: [Errone 22] Invalid mode ('RB') or file name: 'D: \\ *. * '*   

However, a very simple solution would be enough for you: oslistdir < / Code>.

  gt; & Gt; Import OS & gt; & Gt; & Gt; Oslistdir ('D: \\') ['Video', 'Picture', 'Music', 'Document', ...]   

os.listdir Gives a list of files and dirs in a special DIR or windows drive. Once you have a list, then shutil.move for each item.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -