1

到目前为止,我已经从测试目录中测试了这个,没有错误,但我需要脚本来调用其他服务器上的目录。一旦我尝试为批处理文件所在的目录添加 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
4

2 回答 2

1

它需要在一行上或使用括号。

for /f "delims=" %%a in ('dir /b /a-d *.DONE ^| find "%SITE%" /c') do set/p "=%%a,">>%SITE%.txt <nul
于 2013-07-19T01:24:54.647 回答
0
for /f "delims=" %%a in (' dir "[UNC PATH]\*.DONE" /b /a-d ^| find "%SITE%" /c') do (set /p "=%%a,">>%SITE%.txt <nul)
于 2013-07-22T19:31:46.337 回答