title: FOR and MOVE in same statement in a BATCH file
body: <p>I am trying to move multiple .ARC files from sub-directories within a primary directory to one of the other sub-directories. I can get this FOR statement to run just fine if I manually type it in the command line, but running it from script doesn't seem to be working at all (with the variables assigned). </p>
  
  <p>Can anyone see that I am doing something wrong? It's under my impression that I have all the correct syntax in place for this to work without any issues. </p>
  
  <pre><code>:main
  setlocal enabledelayedexpansion
  
      cls
      echo.
      set /P acct=Please type the 9 digit account number you would like to restore: 
      set acctDir=x:\!acct!
      set acctDir2=media1\Setup\setup.exe /cd
      set log=c:\log.txt
  
  
      echo. Starting on !date! !time! on !Computername! &gt;&gt; !log!
      echo.
      echo The account number you selected is: !acct!
      echo.
  
      goto :user
  
  :user
  
      set /p answer=Is this correct (Y/N)? 
      echo.
  
      if /i !answer!==y goto :yes (
      ) else ( 
          echo.
          echo Ok. Let's try again^^!
          echo.
          pause
          cls
          goto :main
          )
      )
  
  :yes
  
      set c=0
      For /f %%a in ('dir !acctDir! /B /A:D') do (
      set /a c+=1
      echo !c!    %%a
      set dir!c!=%%a
      )
  
      echo. 
      set /p userIn="Select a directory [1-!c!]: "
      set userDir=!dir%userIn%!
  
      echo.
      echo You selected !userDir! for your data retrieval.
      echo.
      goto :string
  
  :execute
  
      echo.
      echo The Data Protector Program will now be initialized...
      start !acctdir!\!userDir!\!acctDir2!
  
      goto :string
  
  
  :string
  
      set sumLog=!acctdir!\!userDir!\SummaryLog.txt
      set succ=finished
  
      findstr " .*!succ!" !sumLog!
      if exist errorlevel 0 (
          pause
          goto :move
      ) else (
          goto :eof
      )
  
  :move
      set acctDir3=media1
      set x=x:\!acct!\!userDir!
      set y=x:\!acct!\!userDir!\!acctdir3!
  
      echo !x!
      pause
      echo !y!
      pause
      for /r "!x!" %%i in (*.ARC) do move "%%i" "!y!"
      pause
  
      :: for /r "X:\101004357\Jan_20_2014_6_56_55_953PM" %%g in (*.ARC) do move "%%g" "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1"
  
  
  
  endlocal
  goto :eof
  </code></pre>
  
  <p>Please disregard the Access Denied as I will correct that issue on my own. However, the output I get if I manually run the same FOR statement from the command line is: </p>
  
  <pre><code>X:\&gt;for /r "X:\101004357\Jan_20_2014_6_56_55_953PM" %g in (*.ARC) do move "%g" "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1"
  
  X:\&gt;move "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1\FILES1.ARC"     
  "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1"
  Access is denied.
  0 file(s) moved.
  
  X:\&gt;move "X:\101004357\Jan_20_2014_6_56_55_953PM\Media2\FILES2.ARC"  
  "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1"
  Access is denied.
  0 file(s) moved.
  
  X:\&gt;move "X:\101004357\Jan_20_2014_6_56_55_953PM\Media3\FILES3.ARC"  
  "X:\101004357\Jan_20_2014_6_56_55_953PM\Media1"
  Access is denied.
  0 file(s) moved.
  </code></pre>
  
  <p>If I run it from the script, I get no output except to go to <code>:eof</code>. Please see the output from the script:</p>
  
  <pre><code>Please type the 9 digit account number you would like to restore: 101004357
  
  The account number you selected is: 101004357
  
  Is this correct (Y/N)? y
  
  1    Jan_14_2014_12_49_11_900PM
  2    Jan_20_2014_6_56_55_953PM
  
  Select a directory [1-2]: 2
  
  You selected Jan_20_2014_6_56_55_953PM for your data retrieval.
  
  [2014-01-23 12:15:14 InfoTrace (8209)]DVD Media image creation finished at: Thu Jan 23 12:14:50 2014
  
  Press any key to continue . . .
  x:\101004357\Jan_20_2014_6_56_55_953PM
  Press any key to continue . . .
  x:\101004357\Jan_20_2014_6_56_55_953PM\media1
  Press any key to continue . . .
  Press any key to continue . . .
  </code></pre>
  
  <p>If you notice between the double <code>PAUSE</code> syntax above is where the <code>FOR</code> statement should have ran. But it never does and moves to the second pause without any output or any kind of move, etc. </p>
  
  <p>Any input would be greatly appreciated!</p>