|
|
Source Code Line Counter - Know Of Any ? | ||
Discussion by miCRoSCoPiC^eaRthLinG with 3 Replies.
Last Update: April 5, 2005, 10:43 am | |||
![]() |
|
|
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
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
I saw that you are Regiestered Linux user, so it must be in Linux
CODE
#!/bin/bashEXTENSIONS=".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"
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
Similar Topics:
Sony Stole Open Source Source Code ...
To Hide Your Source Code
Counter Strike: Source
Searching For Freeware Cad Application... (2)
|
(8) Arachnophilia HTML Editing Freeware
|
HOME 





The Joy of Code #16: Adding a score counter
Visual Basic Game Programming Tutorial - Part 1 - Building a Game Loop and Frame Counter
XCode Tutorial Tap Counter - Geeky Lemon Development

