DOS / Windows Utility - llc - Count lines in a Text (ASCII)

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

DOS / Windows Utility - llc - Count lines in a Text (ASCII)

Post by Marcus Tettmar » Thu Apr 02, 1998 11:00 pm

Contributed By: Larry D Woods [email protected]
Submitted On: 03/04/98

Note: With version 5.0 it is now possible to count the number of lines in a file using ReadLn :

Let>count=0
Label>Start
Let>count=count+1
ReadLn>c:\..\myfile.txt,count,line
If>line=##EOF##,end
Goto>Start
Label>end
Message>Number of lines in files = %count%


Original article now follows :
_____________________________________________
Utility Program:  Count no. of lines in text file

         llc - larry's line counter

Format:   llc {parm1} {parm2} ... {parmN}

llc will count the number of lines in a piped text file and generate text lines with
embedded line count.  For example:

dir /b *.txt | lcc

would display a count of the no. of txt files in the directory.  (If you are not familiar
with the /b option of dir, this tells dir to only display the file names, without the
header and trailer records.)

llc will also accept optional parameters that will be displayed, with the line count
embedded within the displayed text.  The tilde (~) defines where the line count is
to be embedded.  For example,

dir /b *.txt | llc [COUNT] Count=~

would display:

[COUNT]
Count=4

(assuming 4 txt files in the directory)

Now, by redirecting the output, you can create an output file.

dir /b *.txt | llc [COUNT] Count=~ > Parms.ini

Remember that you can append to an existing file using '>>' instead of '>' .

dir /b *.bat | llc [BATCH] Batch=~ >> Parms.ini

will add the lines to the previous output file.

What if you want to use the '~' as part of the output text?  By using a special first
parameter, you can redefine the replacement character.  For example,

dir /b *.txt | llc /^ Tilde=~ Count=^

would display:

Tilde=~
Count=4

Note:  1. The line count can be displayed multiple times within the text parameters.
            2. ' llc ? ' will display online documentation.

Get it FREE at http://www.mjtnet.com/scripts/llc.exe

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts