Skip to content

ottles91/project-line-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Project Line Counter

Project Line Counter is a lightweight Python command-line utility designed to help developers quickly analyze the size and structure of their codebases. It recursively scans a project directory, counts lines of code across multiple file types, and provides both a total line count and a breakdown by file extension. With options to include or exclude hidden files, skip specific directories or file types, and ignore non-text/binary files, it's a flexible tool for getting a clearer picture of your project's composition without the overhead of a full-featured code metrics suite.

🚀 Features

  • Scans a directory and its subdirectories
  • Supports multiple file extensions (e.g. .py, .cs, .js, .swift)
  • Counts all files if no --ext argument is provided
  • Optionally include hidden files and directories with --include-hidden
  • Optionally exclude certain file extensions or directories when counting all files
  • Skips unreadable or binary files
  • Provides a breakdown of lines by file type
  • Reports the number of skipped non-text/binary files

🛠️ Requirements

  • Python 3.7 or later

Installing Python

This project requires Python 3.8+.
If you don’t already have Python installed, follow the steps below:

Windows

  1. Download the latest stable release from the official Python website.
  2. Run the installer and make sure to check "Add Python to PATH" before clicking Install Now.
  3. Verify the installation by opening Command Prompt and running:
    python --version

macOS

Python 3 usually comes pre-installed on macOS, but it’s often outdated. It’s recommended to install the latest version via Homebrew:

brew install python

Verify with:

python3 --version

Linux

Debian/Ubuntu:

sudo apt update
sudo apt install python3 python3-pip

Fedora:

sudo dnf install python3 python3-pip

Check Installation with:

python3 --version

Once installed, you can manage dependencies with:

pip install -r requirements.txt

📦 Installation

Clone the repository:

git clone https://github.com/ottles91/project-line-counter
cd line-counter

▶️ Example Usage

Basic usage (count all text-based files in a given directory):

python3 -m LineCounter /path/to/project

Count lines for all Python, Swift and JavaScript files:

python3 -m LineCounter /path/to/project --ext .py .swift .js

Count lines from all files except for .css files:

python3 -m LineCounter /path/to/project --exclude-ext .css

Count all files but skip certain directories:

python3 -m LineCounter /path/to/project --exclude node_modules venv

Combine directory and extension exclusion:

python3 -m LineCounter /path/to/project --exclude node_modules build --exclude-ext .txt .json

Include hidden files & folders:

python3 -m LineCounter /path/to/project --include-hidden

See help:

python3 -m LineCounter -h

Example Output

Counting total lines of code in ./my_project...

Total lines of code: 2500

Lines by file type:
.css: 667
.html: 2204
.js: 91
.md: 43
No Extension: 30

Skipped 10 non-text/binary files.

📜 License

MIT License. Free to use and modify.

About

Custom directory line-counter built in Python. Built to help estimate the overall size of projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages