A CLI tool that collects statistics about the types of file extensions found in a given directory
Project description
File Stats CLI
A command-line tool to recursively scan a directory and collect file extension statistics. It reports:
- Count: Number of files with each extension.
- Max: Size in bytes of the largest file for each extension.
- Total: Total file size in bytes of all files for each extension.
The output can be rendered as a rich table or as plain "pretty" text. You can also sort the results by file extension, count, total size, or max size.
Features
- Recursive Scanning: Traverses directories and subdirectories.
- Multiple Output Formats: Choose between a rich table and a pretty text output.
- Custom Sorting: Sort results by extension (
ext), file count (count), total size (total), or maximum file size (max). - Modern CLI: Built with Typer and Rich.
Requirements
Usage
Examples:
# Scan the current working directory with default options:
poetry run file-stats
# Scan a specific directory:
poetry run file-stats /path/to/directory
# Choose output format ("table" or "pretty"):
poetry run file-stats --output pretty
# Sort the results by a specific field:
poetry run file-stats --sort-by count
poetry run file-stats --sort-by total
poetry run file-stats --sort-by max
# Combine options; for example, scan /tmp sorted by max in pretty format:
poetry run file-stats /tmp --sort-by max --output pretty
Makefile Commands
The provided Makefile includes commands for installation, formatting, linting and testing:
install:
poetry install --sync
format:
poetry run ruff check --fix-only .
poetry run ruff format .
lint:
poetry run ruff check .
poetry run ruff format --diff .
poetry run mypy .
test:
poetry run pytest file_stats_tests -vv
Building the Package
Developers can build the project for distribution using Poetry. This will create a source distribution and a wheel in the dist directory.
poetry bu
## License
This project is licensed under the [MIT License](LICENSE).
---
## Acknowledgements
- Built using [Typer](https://typer.tiangolo.com/) for CLI management.
- Styled with [Rich](https://rich.readthedocs.io/) for beautiful terminal output.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_file_stats-0.1.0.tar.gz.
File metadata
- Download URL: py_file_stats-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.1 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ff3dc7f3aaf13ff5250d8355bbb90a5a2d6a42d1bb225ef676f17ca4b6021d
|
|
| MD5 |
80f8987b675a73f668e254f97d2164a4
|
|
| BLAKE2b-256 |
2607833ec6271e3149cc6119feade837e4cf807b11b314440fe550e2238850ac
|
File details
Details for the file py_file_stats-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_file_stats-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.1 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad7dd8c41c5e5ada8c69b020529fcf1a14841ed8d65935f05f7616a9c2619064
|
|
| MD5 |
849cf28faee722e5c1cbfb755db4d5a7
|
|
| BLAKE2b-256 |
edadca12ef12e86199f66227bd45bee40379617541ea32ee7bd6c3500655176f
|