Jump to content
xisto Community
Sign in to follow this  
miCRoSCoPiC^eaRthLinG

Source Code Line Counter - Know Of Any ?

Recommended Posts

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://forums.xisto.com/no_longer_exists/ - 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

Share this post


Link to post
Share on other sites

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

#!/bin/bashEXTENSIONS=".tex .abc"DIRECTORIES="design flash"if [ -e /tmp/countertemp ]; then	echo "delete /tmp/countertemp to continue"	exit 1fimkdir /tmp/countertempCOUNTERALL="0"COUNTER="1"LINESALL="0"for DIRECTORY in $DIRECTORIESdo	for EXTENSION in $EXTENSIONS	do		COUNTERALL=`expr $COUNTERALL + 1`		find $DIRECTORY -name *$EXTENSION -fprint /tmp/countertemp/_"$COUNTERALL"_.files	donedonewhile [ $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`doneecho $LINESALLrm -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

Share this post


Link to post
Share on other sites

No problem... :PI would sugest to tweak this in two places...:1) make it use also command line arguments... you won't nead to tweak code every time2) 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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.