title: How to move random amount of files & folders with similar names?
body: <p>Needs to be a simple script anyone with XP/Vista/7 can run (no PE or Powershell).</p>
  
  <p>I need to move a random amount of files (eg. 1-15), and also similarly named folders (which are in a different location), to their own folder at the same time. 30 files and 30 folders to choose from:</p>
  
  <pre><code>C:\game\store\XMLs -&gt; C:\game\mod\0.1.2\map\data  
  map01_aaa.xml  
  map02_bbb.xml  
  map03_ccc.xml  
  ...  
  map60_zzz.xml
  
  C:\game\store\models -&gt; C:\game\mod\0.1.2\sky\stuff  
  01_aaa_map  
  02_bbb_map  
  03_ccc_map  
  ...  
  60_zzz_map
  </code></pre>
  
  <p>Hope that makes sense if not I'll go to sleep and try again tomorrow. I read about a dozen questions related to moving random files thoroughly (such as <a href="https://stackoverflow.com/a/5552764/2003492">this one</a>), few hours of google, and reading robvanderwoude.com, I'm not very experienced. If anyone has any suggestions of what to do, what to read, or can give an example I can work off of to accomplish this, I'd appreciate it.</p>
  
  <p><strong>Edit:</strong> Here is the code I have so far, updated with the answer from jimhark:</p>
  
  <pre><code>@ECHO OFF &amp; setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  SET SrcCount=0
  SET SrcMax=15
  FOR %%F IN (C:\game\mod\store\XMLs\*.*) DO IF !SrcCount! LSS %SrcMax% (
  SET /A SrcCount += 1
  ECHO !SrcCount! COPY %F C:\game\mod\0.1.2\map\data\
  COPY %%F C:\game\mod\0.1.2\map\data\
  SET FNAME=%%~nF
  XCOPY /s "C:\game\mod\store\models\!FNAME:~3!"  "C:\game\mod\0.1.2\sky\stuff\!FNAME:~3!\"
  )
  </code></pre>
  
  <p>It's not randomly selecting files though, even with %RANDOM%%%15, it always moves the first 8 files for example. Also the code to move the folders doesn't work, it will only move the files.</p>