title: Is there a way to get the python program to "refresh the sd drive connection"
body: <p>My daughters SD card has gone corrupt, and I'm trying to recover the photos/files. I have tried various recover software but to no avail.</p>
  
  <p>However I have found that if I use MSDOS, I can copy various photos, however intermittently this fails and says "theres no disk in drive" 
  I assuming the file its trying to copy is corrupt, I can overcome this by pulling out the sd card and re-inserting it.</p>
  
  <p>So opportunity for a program! :) - I got the file names via dos, created a text file and knocked up a rough program.... However I keep getting the "theres no disk in drive"</p>
  
  <p>Hence... Is there a way to get the python program to "refresh the sd drive connection"</p>
  
  <p>Many thanks.</p>
  
  <pre><code>#!/usr/bin/env python
  """ File copy program"""
  
  import os
  import shutil
  
  def main(): 
      Basepathfile = os.path.dirname(os.path.abspath(__file__))
      FileName = 'Filenames.txt'
      PrelimPathFile = os.path.join(Basepathfile, FileName )
      PathFile = os.path.normpath(PrelimPathFile)
  
      Filename1 = open(PathFile, 'r')
      Filename2 = 'c:\\Lili\\'
      for line in Filename1:
          line = line.replace('\r\n', '').replace('\r', '').replace('\n', '')
          Filename1 = 'f:\\DCIM\\Camera\\'+ line
          Filename2 = 'c:\\Lili\\'+ line
  
          try:
              shutil.copy2(Filename1, Filename2)
              print 'Copied... '
              print Filename1, '...to...', Filename2
          except:
              print 'Failed to copy ', Filename1, ' to ', Filename2
  
  if __name__ == '__main__': 
      main() 
  </code></pre>