【发布时间】:2016-12-07 19:35:52
【问题描述】:
我正在尝试改进@Tony 在other question 中发布的脚本
@Echo off Set _File=file.txt Set /a _Lines=0 For /f %%j in ('Type %_File%^|Find "" /v /c') Do Set /a _Lines=%%j Echo %_File% has %_Lines% lines.
计算目录和子文件夹中所有文本文件的行数:
@Echo off
setlocal EnableDelayedExpansion
Set _Dir=C:\TEST_DIR\
Set /a _Lines=0
for /R %_Dir% %%f in (*.*) do (
for /f %%j in ('Type !%%f!^|Find "" /v /c') Do Set /a _Lines=!_Lines!+!%%j!
)
Echo %_Dir% has %_Lines% lines.
pause
但我收到错误:“缺少操作数。”
【问题讨论】:
标签: batch-file for-loop cmd window nested-loops