Skip to content

hd1fernando/compress-all

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

All Compressor

A CLI tool for compressing and decompressing files in directories using Brotli compression.

Installation

Using Virtual Environment (Recommended)

Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate  # Linux/Mac
# or: venv\Scripts\activate  # Windows

Install dependencies:

pip install brotli pytest

Global Installation

pip install brotli pytest

Using Install Script

Run the install script to install globally and use compress-all from anywhere:

./install.sh

Add to PATH if needed:

export PATH="$HOME/.local/bin:$PATH"

To update after pulling new changes:

./install.sh

The script automatically detects previous installations and updates them.

Uninstall

To uninstall:

./uninstall.sh

Usage

python src/main.py <path> [options]

Where <path> is a file or directory containing files.

Options

  • -c, --compress Compress files (default)
  • -d, --decompress Decompress .br files
  • -v, --verbose Enable verbose output
  • -r, --remove-original Remove original files after operation
  • -e, --exclude List of directories to exclude (space-separated)
  • -n, --dry-run Show what would be processed without executing
  • -q, --quality Compression quality 1-11 (default: 6)
  • --version Show version number
  • -h, --help Show help message

Examples

Compress all files in a directory:

python src/main.py ./myfiles -c

Decompress .br files:

python src/main.py ./myfiles -d

With verbose output:

python src/main.py ./myfiles -v

Compress and remove original files:

python src/main.py ./myfiles -c -r

Decompress and remove .br files:

python src/main.py ./myfiles -d -r

Exclude directories from compression/decompression:

python src/main.py ./myfiles -c -e temp cache

Exclude a subdirectory (relative path):

python src/main.py ./myfiles -c -e assets/images

Dry run (preview without executing):

python src/main.py ./myfiles -c -n

Compress a single file:

python src/main.py ./myfiles/image.png -c

Decompress a single file:

python src/main.py ./myfiles/image.png.br -d

Fast compression (lower ratio):

python src/main.py ./myfiles -c --quality 1

Maximum compression (slower):

python src/main.py ./myfiles -c --quality 11

How it works

  • Files in the specified directory and its subdirectories are processed recursively
  • Single files can also be compressed or decompressed directly
  • Compressed files get a .br extension added
  • Already compressed files (.br) are skipped during compression
  • Only .br files are processed during decompression
  • Original files are preserved after compression
  • Directories specified in --exclude are skipped entirely

For Developers

Running Tests

Run all tests:

pytest tests/ -v

Run a specific test file:

pytest tests/test_integration.py -v

Created with AI

This project was developed using artificial intelligence.

Tools and LLMs Used

Tool/LLM Purpose
OpenCode AI coding assistant
Claude (Anthropic) Code generation and review

About

A CLI tool for compressing and decompressing files in directories.

Topics

Resources

License

Stars

Watchers

Forks

Contributors