A More Robust Line Counter

Posted On Thu, 23 May 2013

Filed under Batch
Tags: , , , , ,

Comments Dropped 2 responses

In a previous post, I talked about how to count the number of lines in a text file. I explained the technique of piping the output from type file.txt into find /c /v "" and wrapping the whole thing inside a for /f loop to store the result in a variable. A simple and effective solution to a common Batch programming task. 🙂

Too bad it doesn’t work…

continue reading »

Advertisements

Count the Number of Lines in a Text File

Posted On Thu, 9 Aug 2012

Filed under Batch
Tags: , ,

Comments Dropped leave a response

I have of late, wherefore I know not, started writing little Batch programs. Batch is ugly and buggy, but at the same time its raw minimalism makes it capable of performing surprisingly complicated tasks. Ah, but knowing how to exploit this power, therein lies the rub!

Let's start with the seemingly straightforward task of counting the lines in a text file and storing the result in a variable.

Read the rest of this post »