Count lines of code and comments in source files in C, BASIC, and general web files.
Code Counter will search for files of the specified type in the directory from which it's called, and then search recursively in all sub-directories.
Original aim: initiate in a project's top-level directory and provide stats on the whole project.
- Linux
- Windows
codecounter <option> [-s]
option:
-c process C source files: .c, .cpp, .h
-b process BASIC source files: .bas, .bi, .vb
-w process general web files: .html, .htm, .css, .php, .inc, .tpl, .js, .sql
supplementary:
-s suppress individual file breakdown (display only project summary)
For large projects, pipe Code Counter's file-by-file output to a file for later usage, grepping etc:
codecounter -c > cc_out.txt
Download from Releases or directly:
- Linux x64: codecounter
- Windows x32/x64: codecounter.exe
Install FreeBASIC compiler (fbc).
(Linux: fbc x64 version creates more convenient executables.)
Ensure GCC is available: whereis gcc
make
or full process:
make && make install
fbc codecounter.bas -gen gcc -O max -w all
On both Linux and Windows, it's more convenient for Code Counter to be available from any directory location via the $PATH system variable (rather than copying the executable file to the directory where needed).
make install
Or move the codecounter executable to a location such as /usr/local/bin (location must be present in $PATH).
[Windows key + Break] > Advanced tab > Environmental Variables button > click Path line > Edit button > Variable value – append at the end of existing line info: C:\directory\path\to\codecounter.exe;
Thanks to Richard D. Clark (rdc) for his elegant directory recursion function.
Code Counter is released under the GPL v.3.