title: Can't move a file in python? Errno 13- Permission Denied
body: <p>this is my code:</p>
  
  <pre><code>def unpack(folders):
  for folder in folders:
      files = os.listdir(folder)
      print (files)
      while len(os.listdir(folder)) != 0:
          for file in files:
              if os.path.isdir(file)==False:
                  print (file)
                  shutil.move(os.path.join(cur_dir,folder,file),os.path.join(cur_dir,file))
              else:
                  unpack(file)
  
  
      if len(os.listdir(folder))==0:
          os.rmdir(folder)
  </code></pre>
  
  <p>When I call this on the directory this program is in, everything works fine, but I can't copy a file called 'desktop.ini'. This is the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\satvi_000\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 544, in move
      os.rename(src, real_dst)
  FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\\Users\\satvi_000\\Downloads\\others\\desktop.ini' -&gt; 'C:\\Users\\satvi_000\\Downloads\\desktop.ini'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "C:\Users\satvi_000\Downloads\clean_folder.py", line 37, in &lt;module&gt;
      unpack(folders_list)
    File "C:\Users\satvi_000\Downloads\clean_folder.py", line 30, in unpack
      shutil.move(os.path.join(cur_dir,folder,file),os.path.join(cur_dir,file))
    File "C:\Users\satvi_000\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 558, in move
      copy_function(src, real_dst)
    File "C:\Users\satvi_000\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 257, in copy2
      copyfile(src, dst, follow_symlinks=follow_symlinks)
    File "C:\Users\satvi_000\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 121, in copyfile
      with open(dst, 'wb') as fdst:
  PermissionError: [Errno 13] Permission denied: 'C:\\Users\\satvi_000\\Downloads\\desktop.ini'
  </code></pre>
  
  <p>I'm guessing this is a system file or something. How do I get past this? It's not completely necessary to move the file, skipping it is fine.</p>