title: Handling exception while using shutil.copytree to copy a file where permission is denied
body: <p>Consider the following directory tree</p>
  
  <pre><code>Work---&gt;subdir1---&gt;File1
      |         |
      |         ----&gt;File2
      |
      --&gt;subdir2---&gt;File3
  </code></pre>
  
  <p>There exists another similar directory tree</p>
  
  <pre><code>Gold---&gt;subdir1---&gt;File1
      |         |
      |         ----&gt;File2
      |
      --&gt;subdir2---&gt;File3
  </code></pre>
  
  <p>I have to write a script to copy the <code>Work</code> directory to another location. I have been using <code>shutil.copytree</code> for the same.</p>
  
  <p>The problem is, at times (but not always) I may not have permission to access some files, say, <code>File2</code> in the <code>Work</code> directory, and will get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "C:\Script.py", line 81, in &lt;module&gt;
  shutil.copytree(source_loc,dest_loc)
  File "C:\Python32\lib\shutil.py", line 239, in copytree
     raise Error(errors)
     shutil.Error: [('C:\\Work\\subdir1\\File2', 
     'C:\\Dest\\subdir1\\File2', 
  "[Errno 13] Permission denied: 'C:\\Work\\subdir1\\File2'")]
  </code></pre>
  
  <p>In such situations, I will have to copy those corresponding files from the <code>Gold</code> directory.
  Is there a way in which I can automate the copying of the corresponding files from <code>Gold</code> directory through an exception? Say something like:</p>
  
  <pre><code>try:
     shutil.copytree(r'C:\Work',r'C:\Dest')
  except:
     &lt;&lt; Copy Inaccessible Files from Gold &gt;&gt;
  </code></pre>
  
  <p>I was initially thinking about using <code>os.walk</code>, to copy files individually. This way whenever I encounter an exception for a particular file, I will be able to copy that corresponding file from Gold. Is there a better way?</p>