This script counts the lines of code in a C++ codebase. It reads files with the extensions cpp, h, hpp, cmake and CMakeList.txt and ignores blank lines. It also has the ability to ignore certain folders by matching their names to a pattern.
To use this script, you need to have Python 3.7+ installed on your system. You can run the script from the command line by navigating to the directory where the script is located and running the following command:
python script.py path/to/codebase
Where path/to/codebase
is the path to the codebase you want to count lines of code for.
By default, the script will not exclude any folders. If you want to exclude certain folders from the line count, you can edit the exclude_folders
variable in the script and add the names of the folders you want to exclude.
The script will output the total number of lines of code in a readable format, displaying the number of lines in millions and hundreds.
If there is an error reading a file as utf-8, the script will try to read it again using the ansi encoding.