Monday, August 3, 2015

How to Check Your LOC?

[For Windows/cmd.exe]

So this question just popped up in mind while looking at an informational site http://www.informationisbeautiful.net/visualizations/million-lines-of-code/. What are the lines of code for the project in my company for a platform we've been writing.
I did some digging and created a batch file that tells line of code of all the code files inside your directory recursively.
The batch file has only one command and I redirected the output of that command in an out.txt file in the current folder.
Contents of this batch file are as follows
findstr /RN /s "^" .\\*.scala | find /c ":" 1>out.txt

What this command does?
It finds all the strings with \n inside the all the files ending with the extension .scala (you can change in your case, a simple use of commandline wildcards) and then redirects those lines into "find" that is another command. "find" program simply counts the lines and this output goes into the output stream connected to the out.txt file in the present working directory.

How I can calculate my project overall lines of code?
Simply copy the command mentioned above. Replace the .scala with your code extension (multiple extensions also can be added). Put this command inside some filename.bat and save that .bat file inside the root directory of your project. As you will run this batch file. Output will be generated at present working directory named out.txt as mentioned in the command containing your lines of code count.

Don't forget to provide your feedback. Stay tuned for more tweaks.

No comments :

Post a Comment