Reputation: 115
I am trying to find a easy way to display how many lines of text there is in a text file, but google in some kind of way keeps showing these totally advanced scripts that makes no sence.. as always i try not to keep things to complicated and as minimal as possible.
echo +hehe0 > ex.txt
set num=0
:loop
set /a num=%num%+1
echo +hehe%num% >> ex.txt
if %num% equ 6 goto end
findstr /n "+" ex.txt
pause
i hope this will make good sence, and help others as well, one love
Upvotes: 0
Views: 37
Reputation: 79982
To display # of lines:
type filename|find /c /v ""
To assign # of lines to a variable:
for /f %%a in ('type filename^|find /c /v "" ') do set var=%%a
(%%a
if within a batchfile; %a
if directly from the prompt.)
Upvotes: 1