RSS:
Publications
Comments

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 Comments to "Getting the number of lines in a text file"

  1. July 31, 2010 - 2:54 am | Permalink
  2. October 9, 2008 - 2:08 am | Permalink

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

  3. October 9, 2008 - 8:49 am | Permalink

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

  4. January 13, 2009 - 2:13 pm | Permalink

    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!

  5. February 27, 2009 - 5:48 pm | Permalink

    awesome script, extremely helpful. thank you!

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <div align="" class="" dir="" id="" lang="" style="" xml:lang=""> <embed style="" type="" id="" height="" width="" src="" object=""> <iframe width="" height="" frameborder="" scrolling="" marginheight="" marginwidth="" src=""> <img alt="" align="" border="" class="" height="" hspace="" longdesc="" vspace="" src="" style="" width="" title="" usemap=""> <map name="" id=""> <object style="" height="" width="" param="" embed=""> <param name="" value=""> <pre style="" name="" class="" lang="" width="">