title: Copy a file including it's relative path
body: <p>I need to copy a large number of files to a backup folder but I want to maintain their relative paths. I only need specific files; i.e.</p>
  
  <pre><code>C:\scripts\folder\File.ext1
  C:\scripts\folder2\file2.ext2
  C:\scripts\file3.ext1
  </code></pre>
  
  <p>But I only need to copy the ext1 files like so:</p>
  
  <pre><code>C:\backup\folder\File.ext1.bak
  C:\backup\file3.ext1.bak
  </code></pre>
  
  <p>The source paths are of multiple depths.
  This is what I have to copy the files:</p>
  
  <pre><code>$files = gci -path C:\scripts\ -recurse -include *.ext1 
  $files | % { Copy-Item $_ "$($_).bak"; move-item $_ -destination C:\backup\ }
  </code></pre>
  
  <p>This just dumps all the files into C:\backup\ and does not appear to get any of the paths. Not sure how that part would be done.</p>