title: How to batch copy files based on a list (txt) of PREFIXES
body: <p>My filenames contain somewhat standardized prefixes. Generally, the format is <code>yyyy-99999-xx</code>.</p>
  
  <p>Filename examples:</p>
  
  <pre><code>2015-12345-NY-0 Coney Island
  2015-12345-NY-1 Coney Island
  2015-54321-NY Coney Island
  </code></pre>
  
  <p>As you can see, there can be multiple files containing identical characters <code>1</code> thru <code>n</code>. I would like to copy files from a folder by searching for prefixes contained in a .txt file list.  </p>
  
  <p>Basically, I would like to "refine/expand" the process shown in <a href="https://stackoverflow.com/questions/6257948/batch-copy-a-list-txt-of-files">Batch: Copy a list (txt) of files </a> so that <code>file-list.txt</code> - I've changed to <code>Prefix-List.txt</code> - contains only the filename "prefixes" of the files to copy.  I had to change the <strong>xcopy</strong> switch to <code>/K</code> in order to copy any files.  </p>
  
  <p>Additionally, I would like to redirect errors to <code>Errors.txt</code></p>
  
  <p>"Nice to have" would be including subfolders in the search.</p>
  
  <p>Using my filename examples above:</p>
  
  <p><code>2015</code> would copy 3 files.<br>
  <code>2015-12345-NY</code> would copy 2 files.<br>
  <code>2015-12345-NY-1</code> would copy 1 file.</p>
  
  <p>Here's my .bat file  </p>
  
  <pre><code>set src_folder=d:\JAR\source
  set dst_folder=d:\JAR\destination
  for /f "tokens=*" %%i in (File-list.txt) DO (
      xcopy /K "%src_folder%\%%i" "%dst_folder%"
  )
  </code></pre>
  
  <hr>
  
  <p>Mofi's solution is exactly what I asked for.  Now I'd like to expand a little by changing the destination directory name &amp; adding a date-time prefix.     </p>
  
  <p>I have 2 questions<br>
       1. How to get Mon=08 (instead of Aug)?<br>
       2. What is syntax for MKDIR using a variable?       </p>
  
  <p>Here's the coding I'm using (modified from <a href="https://stackoverflow.com/questions/10945572/windows-batch-formatted-date-into-variable">Windows batch: formatted date into variable</a> ).         </p>
  
  <pre><code> @echo off
   setlocal 
   for /f "skip=8 tokens=2,3,4,5,6,7,8 delims=: " %%D in ('robocopy /l * \ \  /ns /nc /ndl /nfl /np /njh /XF * /XD *') do (
   set "dow=%%D"
   set "month=%%E"
   set "day=%%F"
   set "HH=%%G"
   set "MM=%%H"
   set "SS=%%I"
   set "year=%%J"
   SET "DESTINATION=%%J%%E%%F%%G%%H%%I-EXTRACTION"
  )
  
   echo Day of the week: %dow%
   echo Day of the month : %day%
   echo Month : %month%
   echo hour : %HH%
   echo minutes : %MM%
   echo seconds : %SS%
   echo year : %year%
   echo DESTINATION : %DESTINATION%
  
   endlocal
  
   MKDIR {"%DESTINATION%"}
  </code></pre>