title: Using robocopy instead of xcopy in batch file loop
body: <p>I've got a batch file I've been using to track down all the files in a directory (and its subfolders) that contain a list of around 15 product numbers, entered as a space-separated list. (For example, "54323 12345 68483 234 9993384 29944".)</p>
  
  <p>However, I'm basically having it search through a massive image pool twice per product. Since I usually have a list of about 15 products to pull images for, that can take a while, since it has to search the whole folder 30 times. (Files are either named 12345.jpg or 12345_n.jpg.)</p>
  
  <p>Is there a way to use Robocopy (or something else) to speed things up?</p>
  
  <p>Here's my batch file right now:</p>
  
  <pre><code>set SourceFolder=\\ImagePoolNetworkLocation
  set TargetFolder=C:\Users\BevansDesign\Desktop\Images
  set /p SKUList=SKU Numbers:
  for %%i in (%SKUList%) do (
      xcopy /s %SourceFolder%\%%i.* %TargetFolder%\
      xcopy /s %SourceFolder%\%%i_*.* %TargetFolder%\
  )
  </code></pre>
  
  <p>I was thinking that if I can enter the loop into the robocopy command itself, I could have it look for <em>all</em> the files in the first search. This is basically the logic chain (I think) but I don't know how to insert the "for" function into the robocopy call.</p>
  
  <pre><code>robocopy /s %SourceFolder%\ %TargetFolder%\ [for %%i in (%SKUList%) do (%%i.* and %%i_*.*)]
  </code></pre>
  
  <p>Is this possible? I'm pretty bad at basic programming stuff like this.</p>
  
  <p>Thanks for the help, or even just pointing me in the right direction!</p>