我真的很新.Bat脚本,我正在尝试整合一个嵌套循环过程,其中脚本计算在"待定"中的文件数量。如果文件夹低于一定数量,它会到达"来源"要删除一定数量文件的文件夹。如果金额匹配,那么它将移动到另一个循环,在那里计算有多少文件在" docs"文件夹,再次如果它低于设定的数量,那么来自"待定"如果没有移动,那么让它进入timecount 30秒并从第一个循环开始。
@echo off
setlocal enabledelayedexpansion
:: loop1 reads through the pending folder to determine if there are files in it.
:: if there are the min amount of files the process moves to loop2 if not then it
:: adds files from the source to the pending
:loop1
:: folder names and counts
set acount=0
set bcount=2
set ccount=0
set gcount=2
set srcdir=C:...\sourcefolder1
set dstdir=C:...\pendingfolder
:: counts files in dstdir and determine if files need to be added
:: or can move on to next loop
for /f %%F in ('dir /b %dstdir%') do set /a acount+=1
if %acount% GEQ %bcount% goto loop2
::add files to dstdir
pushd %srcdir%
for %%i in (*.txt) do (
set /a ccount+=1
move %%i %dstdir%\%%i
if !ccount! GEQ %gcount% goto loop2
)
popd
:: loop2 checks to see if there are any files in the docs folder. if there is a min amount it goes to timecount
:: if there are not a min amount, files from pending get added to docs.
:loop2
:: folder names and counts
set dcount=-5
set fcount=2
set mcount=0
set srcdir=C:...\pendingfolder
set dstdir=C:...\docs
for /f %%F in ('dir /b %dstdir%') do set /a dcount+=1
if %dcount% GEQ %fcount% goto timecount
::add files to dstdir
pushd %srcdir%
for %%i in (*.txt) do (
set /a mcount+=1
move %%i %dstdir%\%%i
if !mcount! GEQ %fcount% goto timecount
)
popd
:timecount
TIMEOUT 30
goto loop1
PAUSE
使用上面的代码我得到"命令的语法不正确"任何帮助将不胜感激。