Path information must not be within IN()
clause when using FOR /R
. The root path should follow the /R
option instead.
@echo off
:CountLines
setlocal
set /a totalNumLines = 0
for /r %1 %%F in (*.cpp *.h *.hpp *.cs *.c) do (
for /f %%N in ('find /v /c "" ^<"%%F"') do set /a totalNumLines+=%%N
)
echo Total number of code lines for %1 = %totalNumLines% >>log.txt
I don't remember the difference, but type file|find /c /v ""
and find /c /v "" <file
can give different results. I don't remember what the trigger condition is, or which is better.