Count the number of lines in a file

Solved
Ka-El Posted messages 279 Status Member -  
 Ka-el -
Hello,
I have a file with a certain number of lines.
I would like to know the command that will allow me to find out how many lines the file has.
In Unix, I would of course use the command "wc -l", but in batch, I cannot find an equivalent...
For now, I have tried this:
set /a compt=0
for /f "delims=" %%i in ('type %Fichiers_plein_de_lignes%') do (
set /a compt+=1
echo !compt!>> %résultat%
)

But in the result file, each line is counted while I need the total sum of the lines.
Does anyone have an idea?
Thank you in advance for your help.
Ka-el

1 answer

  1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
     
    hello
    retrieve the result once the for loop is finished
    set /a compt=0
    for /f "delims=" %%i in ('type %Fichiers_plein_de_lignes%') do (
    set /a compt+=1
    )
    echo !compt!> %résultat%

    another method
    find /v /c "" < fichier.txt
    0
    1. Ka-el
       
      Hi Dubcek,
      Great as always!
      Thank you for your effective help.
      Have a nice day.
      Ka-El
      0