代码如下:
@Echo off
Set _File=SQLQuery.txt
Set /a _Lines=0
For /f %j in ('Type %_File%^|Find "" /v /c') Do Set /a _Lines=%j
Echo %_File% has %_Lines% lines.
当我作为.bat文件运行时,它会给我一个错误,因为该命令的语法不正确',当我运行上述所有命令时,它运行成功。为什么会这样?
答案 0 :(得分:0)
试试这个:
@Echo Off
(Set _File=SQLQuery.txt)
(Set _Lines=)
For /F %%I In ('Find /V /C ""^<"%_File%"') Do (Set _Lines=%%I)
If Defined _Lines Echo(%_File% has %_Lines% line(s).
Pause