Thought and Freedom

Articles for those who think. By Terry Pearson

Getting the number of lines in a text file

with 5 comments

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.

Related posts:

  1. Text editing made cooler! If you are a web site developer, you know how important it is to make your users feel comfortable in  using your applications. It is always nice to provide the...
  2. How do I use an MD5 checksum? If you followed the links on my last post, one of them would have taken you to the Torpark web browser download page. When downloading Torpark, you are given an...
  3. Learning about Applets Web programming can be as simple or as complex as you want it to be. The easiest web publication is a simple text file. You could upload it to the...

Written by Terry Pearson

September 23rd, 2008 at 9:09 pm

Posted in Programming

5 Responses to 'Getting the number of lines in a text file'

Subscribe to comments with RSS or TrackBack to 'Getting the number of lines in a text file'.

  1. Like or Dislike: Thumb up 0 Thumb down 0

    Anonymous

    31 Dec 69 at 18:00

  2. That cool. I still prefer to count the lines in a file manually because it just helps my counting ability so much.

    Like or Dislike: Thumb up 0 Thumb down 0

    Trevor Pearson

    9 Oct 08 at 02:08

  3. ugh VBscript makes my brain hurt… C# all the way!

    Like or Dislike: Thumb up 0 Thumb down 0

    Chris Mau

    9 Oct 08 at 08:49

  4. 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!

    Like or Dislike: Thumb up 0 Thumb down 0

    Dave

    13 Jan 09 at 14:13

  5. awesome script, extremely helpful. thank you!

    Like or Dislike: Thumb up 0 Thumb down 0

    pinkISH

    27 Feb 09 at 17:48

Leave a Reply


Creative Commons License
Terry Pearson - The Blog by Terry Pearson
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.