RSS

Counting Source Lines

22 Feb

I rarely count the number of lines of source — but here is a quick script to do it.

I think it is a mistake to count lines, because it rewards the wrong kinds of behaviors.  Even being aware of the number of lines has a tendency to make you do the wrong things.  However, I work with some very conservative departments that insist on reporting lines.

Because I rarely count them, I always forget the script to do it on windows. So I am putting it here so I can find it in the future when needed.

This relies on the old NTRESKIT program called WC.EXE. This counts lines, words, and characters.

The other thing to know is how to iterate across the file system. Here is the script.

FOR /F %G IN ('dir /s /b') DO c:\NTRESKIT\WC.EXE -l %G >>out.txt

starting at the current directory, this will recurse through all the folders, and count the lines appending each to the out.txt file. Take this file into a spreadsheet and sum the first column.

I am sure there are way kewler ways to do this, but since I do this rarely, it works….

Advertisements
 
Leave a comment

Posted by on February 22, 2016 in Coding

 

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: