到目前为止,我已经从测试目录中测试了这个,没有错误,但我需要脚本来调用其他服务器上的目录。一旦我尝试为批处理文件所在的目录添加 UNC,脚本就无法创建 %SITE%.txt。
这是有问题的行:
for /f "delims=" %%a in ('dir /b /a-d *.DONE ^| find "%SITE%" /c') do <nul
完整文件:
@ECHO OFF
SET LIMIT=7
SET SITE=04338
SET SITEFOLDER=D:\Test\Veracity
SET SITEFILE="%SITE%.txt"
SET SAVEFILE="count%SITE%.txt"
SETLOCAL ENABLEDELAYEDEXPANSION
REM Get the current count or start a new file if it does not exist.
IF EXIST %SAVEFILE% GOTO READFILE
ECHO 0 >%SAVEFILE%
:READFILE
SET /P COUNT= <%SAVEFILE%
REM Increment the save file value by one.
FOR %%B IN ( "%SAVEFILE%" ) DO (
CALL :ADD_ONE
)
ECHO %COUNT% >%SAVEFILE%
for /f "delims=" %%a in ('dir /b /a-d *.DONE ^| find "%SITE%" /c') do <nul
set/p "=%%a,">>%SITE%.txt
GOTO CHECK_VALUE
:ADD_ONE
SET /A COUNT+=1
GOTO :EOF
REM Conditionally reset the counter and do something.
:CHECK_VALUE
IF %COUNT% LSS %LIMIT% EXIT /B
DEL %SAVEFILE% 2>NUL
IF EXIST %SITEFILE% DEL %SITEFILE%
ECHO