@echo off
set str="382 -VB814266"
set file="110715*.txt"
type %file% 2>nul | findstr /c:%str% >sum.txt
for /f %%a in (' "type %file% 2>nul | find /c %str%" ') do set n=%%a
echo %n%
pause
我修改了变量但返回仍然是0,我把数据源的截屏发上来了,这是我修改了参数的您的代码:
:echo off
u:
cd MTN\OPSDATA_BKUP
set str="382 -v143788"
set file="200718*.txt"
type %file% 2>nul | findstr /c:%str% >sum.txt
for /f %%a in (' "type %file% 2>nul | find /c %str%" ') do set n=%%a
echo %n%
pause