Loading...


bookmark - Source Code Line Counter - Know Of Any ?

Source Code Line Counter - Know Of Any ?

 
 Discussion by miCRoSCoPiC^eaRthLinG with 3 Replies.
 Last Update: April 5, 2005, 10:43 am
 
bookmark - Source Code Line Counter - Know Of Any ?  
Quickly Post to Source Code Line Counter - Know Of Any ?  w/o signup Share Info about Source Code Line Counter - Know Of Any ?  using Facebook, Twitter etc. email your friend about Source Code Line Counter - Know Of Any ? Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Hi,
Do you guys know of any Source Code Line Counter - that's NOT LIMITED to a single file - but would take a whole directory or choice of files and list the total number of lines in all of them ??? Have searched far and wide but couldn't find one :P

Actually, never mind. I found an excellent one at: http://www.codeproject.com/macro/linecount.asp - it's FREE and best part is it plugs itself into both Visual Studio 6 and VS.NET 2003 - and does a one-click line count of your whole project. Stats are broken up into total line count, remarked lines, blank lines etc. Very very handy. Even the source code is up there.

But I'm still looking for one, that'd run independent of any IDE and parse whole directories at a time based on file extensions. If you guys come across any, please post in here.

Thanks :P

   Tue Apr 5, 2005    Reply         

Hi...

I saw that you are Regiestered Linux user, so it must be in Linux :P... We TuxLikers should help each others, so I wrote some bash that would make it for you :P hope it would be enough...

CODE

#!/bin/bash

EXTENSIONS=".tex .abc"
DIRECTORIES="design flash"

if [ -e /tmp/countertemp ]; then
echo "delete /tmp/countertemp to continue"
exit 1
fi

mkdir /tmp/countertemp

COUNTERALL="0"
COUNTER="1"

LINESALL="0"

for DIRECTORY in $DIRECTORIES
do
for EXTENSION in $EXTENSIONS
do
COUNTERALL=`expr $COUNTERALL + 1`
find $DIRECTORY -name *$EXTENSION -fprint /tmp/countertemp/_"$COUNTERALL"_.files
done
done

while [ $COUNTER -le $COUNTERALL ]
do
FILES="/tmp/countertemp/_"$COUNTER"_.files"
LINES=$(wc "$FILES"|awk '{print $1}')
LINE_NUMBER="1"
while [ $LINE_NUMBER -le $LINES ]
do
FILENOW=$(tail +$LINE_NUMBER "$FILES"|head -1)
LINENOW=$(wc "$FILENOW"|awk '{print $1}')
LINESALL=`expr $LINESALL + $LINENOW`
LINE_NUMBER=`expr $LINE_NUMBER + 1`
done
COUNTER=`expr $COUNTER + 1`
done
echo $LINESALL
rm -r /tmp/countertemp


You enter directories that contains your files (it would look in sub directories to), and file extensions that you want get counted... the result is number of lines from all those files...

is this what you mean or you was talkin about something else?

PS.: you can modyfi it of course... - "all right are given to all" :o

   Tue Apr 5, 2005    Reply         

Woowoowoow !!! Thanks a tonne buddy :P That's EXACTLY what I was looking for :P Thanks for getting me started.. now I can happily mod that to generate keyword count as well ... Damned Cool !!

   Tue Apr 5, 2005    Reply         


No problem... :P

I would sugest to tweak this in two places...:

1) make it use also command line arguments... you won't nead to tweak code every time
2) you probably would like to change way the number of lines if give, just change last echo, to something else, or send stream to file...

this would be probably more usesfulll than now... probably you can get it easier, but I just like bash, since it is portable at all Lins :P

   Tue Apr 5, 2005    Reply         

Quickly Post to Source Code Line Counter - Know Of Any ?  w/o signup Share Info about Source Code Line Counter - Know Of Any ?  using Facebook, Twitter etc. email your friend about Source Code Line Counter - Know Of Any ? Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Sony Stole Open Source Source Code ...

As you may or may not know, SONY has released a Anti- DRM root kit. Allowing home users to remove copy protection and other nasties on media they own legally. However, it seems that Open source programmers have been analysing the Closed Source Software, and found that it contains ...more

   17-Nov-2005    Reply         

To Hide Your Source Code

protect your source code! follow these easy 5 steps: [note=szupie]Copied from http://www.cgiscript.net/cgi-script/csNews...wone&id=19&op=t[/note] [q ...more

   20-Mar-2006    Reply         

Counter Strike: Source

I was thinking about buying this game. I recently played it at an Internet Cafe, and throughly enjoyed it. After reading reviews of what people have thought of the game i was starting to have second thoughts. There were lots of people that didn't like the game and there was many bad reviews. ...more

   29-Jul-2006    Reply         

Searching For Freeware Cad Application...    Searching For Freeware Cad Application... (2) (8) Arachnophilia HTML Editing Freeware  Arachnophilia HTML Editing Freeware