title: How to copy certain files (w/o folder hierarchy), but do not overwrite existing files?
body: <p>I need to copy all <code>*.doc</code> files (but not folders whose names match <code>*.doc</code>) from a network folder <code>\\server\source</code> (including files in all nested folders) to a local folder <code>C:\destination</code> without preserving the nested folders hierarchy (i.e. all files should go directly into <code>C:\destination</code> and no nested folders should be created in <code>C:\destination</code>). In case there are several files with the same name from different subfolders of  <code>\\server\source</code>, only the first one should be copied and never overwritten then — all conflicting files found later should be skipped (there could be many cases like this, and the skipped files should not be trasferred over the network, otherwise it would take too much time). Here is my attempt to implement it in PowerShell:</p>
  
  <pre><code>cp \\server\source\* -Recurse -Include *.doc -Container:$false -Destination C:\destination
  </code></pre>
  
  <p>There are at least two problems with this command:</p>
  
  <ul>
  <li>It copies folders whose names match <code>*.doc</code> too.</li>
  <li>In case of conflicting names any file found later is transferred over the network and overwrites the previous one.</li>
  </ul>
  
  <p>Can you suggest how to fix these problems?<br>
  Implementations using <code>copy</code>, <code>xcopy</code>, <code>robocopy</code>, <code>cscript</code> or <code>*.bat</code>, <code>*.cmd</code> are also welcome.<br>
  The local OS is <em>Windows 8</em> and the file system is NTFS.</p>