Welcome Guest ( Log In | Register )




                Web Hosting

 
Reply to this topicNew Topic
Source Code Line Counter - Know Of Any ?
miCRoSCoPiC^eaRt...
post Apr 5 2005, 03:22 PM
Post #1


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36


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

    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 smile.gif
Go to the top of the page
 
+Quote Post
Giniu
post Apr 5 2005, 04:52 PM
Post #2


Penguin Holmes
Group Icon

Group: Members
Posts: 225
Joined: 22-March 05
From: Poland
Member No.: 3,163


Hi...

I saw that you are Regiestered Linux user, so it must be in Linux smile.gif... We TuxLikers should help each others, so I wrote some bash that would make it for you smile.gif 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" smile.gif
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Apr 5 2005, 05:36 PM
Post #3


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36


Woowoowoow !!! Thanks a tonne buddy smile.gif That's EXACTLY what I was looking for smile.gif Thanks for getting me started.. now I can happily mod that to generate keyword count as well ... Damned Cool !!
Go to the top of the page
 
+Quote Post
Giniu
post Apr 5 2005, 05:43 PM
Post #4


Penguin Holmes
Group Icon

Group: Members
Posts: 225
Joined: 22-March 05
From: Poland
Member No.: 3,163


No problem... smile.gif

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 smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No new   21 WeaponX 2,411 5th January 2009 - 04:44 PM
Last post by: yordan
No New Posts   16 spacewaste 6,330 29th December 2008 - 10:02 PM
Last post by: miladinoski
No New Posts   11 sendto 6,986 26th December 2008 - 12:59 PM
Last post by: iG-nwaynge
No New Posts   1 TavoxPeru 123 18th December 2008 - 10:30 AM
Last post by: wutske
No New Posts 0 tek3D 235 13th December 2008 - 01:22 PM
Last post by: tek3D
No New Posts   5 veerumits 209 27th November 2008 - 07:56 PM
Last post by: yordan
No new   36 master_nero 5,106 24th November 2008 - 09:59 PM
Last post by: toby
No New Posts   0 BuffaloHELP 312 24th November 2008 - 03:10 AM
Last post by: BuffaloHELP
No New Posts   18 x2crazy4shadyx 2,511 16th November 2008 - 11:18 PM
Last post by: Guest
No New Posts   4 khalilov 294 21st October 2008 - 03:44 PM
Last post by: yordan
No New Posts   2 ejasoft 878 23rd September 2008 - 11:30 AM
Last post by: magiccode9
No New Posts   4 Kyle Perkins 1,290 21st September 2008 - 11:31 AM
Last post by: Quatrux
No New Posts   10 cool 1,532 20th September 2008 - 12:49 AM
Last post by: sparkx
No New Posts   14 TavoxPeru 2,250 15th September 2008 - 01:24 PM
Last post by: yordan
No New Posts   3 xboxrulz 1,541 13th September 2008 - 08:04 PM
Last post by: Guest