title: batch script to loop through multiple folders from 1 directory to another
body: <p>I have no experience in writing batch scripts, but I feel this is an opportunity to give this a shot. Essentially, I have folders with the same weekending dates in two directories. I want to write a script that loops through all the folders in the first directory and move files from each folder to the same folder in another directory.</p>
  
  <p>E.g.</p>
  
  <p>\10.25.2.100\f$\Download\A -- first directory</p>
  
  <p>Folders named:</p>
  
  <p>201310
  201311
  201312
  201313</p>
  
  <p>\10.25.2.100\d$\Download\B -- second directory</p>
  
  <p>Folders named:</p>
  
  <p>201310
  201311
  201312
  201313</p>
  
  <p>In 201310 for the first directory, I want to move 2 files in there to the second directory of 201310.</p>
  
  <p>I am thinking of modifying this script but I have no experience what the syntax means:</p>
  
  <pre><code>@ECHO OFF
  SETLOCAL
  SET source= \\10.25.2.100\f$\Download\A
  SET destroot=\\10.25.2.100\d$\Download\B
  SET cdtl=0
  :loploop
  SET /a cdtl+=1
  FOR /f "tokens=%cdtl%*delims=\" %%i IN ("%source%") DO IF NOT "%%j"=="" GOTO loploop
  FOR /f "delims=" %%i IN (
      ' dir /b/s/ad "%source%\converted" '
      ) DO CALL :movedest "%%~dpni%"
  )
  GOTO :eof
  
  :movedest
  SET destdir=%~1
  FOR /f "tokens=%cdtl%*delims=\" %%d IN (%1) DO SET destdir=%destroot%\%%e
  ECHO MD "%destdir%" 2&gt;NUL
  ECHO MOVE /y "%~1\*.*" "%destdir%\"
  GOTO :eof
  </code></pre>
  
  <p>I see this as a huge loop, where it's looping through all the folders in the first directory and checking for those 2 files, then comparing the weekending dates of the  folders in the second directory. If they match, put the two files in there.</p>