Funcion, Saber las lineas de un Archivo

Iniciado por ANTRAX, Julio 18, 2011, 09:33:45 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Código: dos
:: Autor ne0x
:: Sintaxis

:: call:lineas [ruta] [variable]
:: ruta Ruta del archivo
:: variable Nombre de la variable en la que se almacenara el resultado

:lineas
set cont=0
if not exist %1 goto:EOF
for /F %%A IN (%1) DO call:texto
set %2=%cont%
goto:EOF

:texto
set /a cont=1+cont
goto:EOF


Bien, ese código no necesita llamar  a otra función puedes hacer el FOR /F "tokens=*" %%A IN (file.txt) DO (set/a x+=1)" y luego mostrar el %x%
O utilizar:
Código: dos

type archivo.txt | find /v /c "" < archivo.txt

que es más corto..

Saludos.
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login