I'm trying to use a batch file to move files in blocks of 30 if there are less than 20 files in %DataLoc%
. I modified code from a prior question. The problem is in the FMove
section of the file. No matter what I put in the for
line, it gives me an error.
I want this to have the %HoldLoc%
value, but have been hard coding it because of errors I get.
The environment is Windows 2008 R2 server.
Variations I have tried, as well as with and without quotes in the parentheses:
FOR %F IN (%HoldLoc%)
FOR %F IN (%%HoldLock%)
FOR %F IN (c:\Play\hold\*.tmp)
My Code:
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
echo on
set DataMax=20
set DataLoc=C:\Play\Data
Set HoldLoc=C:\Play\Hold
set count=0
FOR /F %%a in ('DIR /B %DataLoc%\*.tmp') do set /A count=count+1
if %count% GEQ %DataMax% (Goto Exit) else (GOTO FMove)
:FMove
Echo Gather Top 30 files
set SrcCount=0
set SrcMax=30
echo %HoldLoc%
FOR %F IN (c:\Play\hold\*.tmp) DO IF !SrcCount! LSS %SrcMax% (
SET /A SrcCount += 1
move /y %F "%DataLoc%"
)
Problem is that I get this in the output window, why won't the C
be seen?
C:>set /A count=count+1
C:>if 19 GEQ 20 (Goto Exit ) else (GOTO FMove )
C:>Echo Gather Top 30 files
Gather Top 30 files
C:>set SrcCount=0
C:>set SrcMax=30
C:>echo C:\Play\Hold
C:\Play\Hold
\Play\hold\*.tmp) was unexpected at this time.
C:>FOR \Play\hold\*.tmp) DO IF !SrcCount! LSS 30 (
C:>