title: copy directories with matching string and all sub-directories and files
body: <p>I've got a beginner question. I'm trying to use XCOPY to copy all directories beginning with the string "44*" and all files and sub-directories within, regardless of their names.</p>
  
  <p>I've got this to work to grab the appropriate files, but the directory structure isn't coming along. </p>
  
  <pre><code>@echo off
  for /f "delims=" %%a in ('dir /b/ad 
  "C:\sourcepathgoeshere\44*" ') do xcopy /s /i /v 
  "C:\sourcepathgoeshere\%%a\*" 
  C:\destinationpath
  </code></pre>
  
  <p>I was able to copy the structure first with <code>/t</code>, but that just made a bunch of empty directories with all the files beneath.</p>
  
  <p>Thanks for help putting these basic pieces together.</p>