Getting the number of lines in a text file

This may be something trivial, but it saves me some time…

Today I wrote a quick VB Script that will count the lines of a text file. This could be useful if you need to quickly verify that some program is outputting the right number of lines to a target file. You can also place it in your windows path location. Then just type “lines filex” from the command prompt to instantly tell how many lines exist in a file (where filex is the name of your file).

Windows Scripting File Icon
files.vbs

I have tested the script on XP Pro SP2 and Vista Home Premium Service Pack 1

Anyway, I find it useful while working on test cases at work. Sometimes, its the little things that save you lots of time.

To use the script, simply drag and drop any text file to it. It will pop up with the number of lines.

5 thoughts on “Getting the number of lines in a text file

  1. I was seriously looking everywhere to find out how I can parse a text file to get the input. I tried writing a script using php, it didn’t work. This approach looks like a great solution. Now I have an idea on how to tie things into my design. Thanks for sharing!

Leave a Reply