Batch counting number of lines of text file without blank -
i got 2 text files different formats,let says have known there 4 non-empty lines in file,shown below (1st valid, 2nd invalid).
aaa
bbb
ccc
end
(blank line)
(blank line)
aaa
bbb
(blank line)
ccc
end
any "for loop" implementations/ways distinguish 1st file has 4 non-empty lines can tell it's valid , 2nd file has blank line in middle can tell it's invalid.
because got loop code can count non-empty line number,applying code in 2 files,it gives me line number=4,which don't want cause 2nd file invalid format. for-loop code
set count=0 /f %%a in (%text_file%) set /a count+=1 echo %count%
any suggestion identify 2 files using lines-counting method?
or can tell me how count number of lines starting until critical string "end",thanks in advance^.^
for /f "tokens=1 delims=:" %%i in ('findstr /n "^end$" %text_file%') set endline=%%i echo %endline%
this finds linenumber of (last) line, equal <startofline>end<endofline>
Comments
Post a Comment