Skip to main content

A Python utility for zipping directories and files

Project description

Automate dir zipping⚡️

Project Description

Simple Python implementation for (un-)zipping dirs.

Features

  • (de-)compress and list files and dirs as required
    • run command for zipping dirs/files of choice
    • run command for extracting already compressed dirs/files of choice
    • run command for listing compressed dirs/files of choice

Prerequisites

  • Python 3.12+
  • Git
  • uv (recommended) or pip

Usage

Command Line Interface

Case 1: Compress items from current working directory (cwd)

# Basic compression in cwd
$ uv run zippa pack foo.txt bar.py
$ uv run zippa pack foo.txt dir1/ bar.py
$ uv run zippa pack .

# Specify output location (can be anywhere)
$ uv run zippa pack . --output /path/to/backup.zip
$ uv run zippa pack *.py --output ../python_files.zip
$ uv run zippa pack . --output ~/backups/project.zip

Case 2: Compress items from external directory, output in that directory

# Compress everything in external directory, output there
$ uv run zippa pack . --chdir ~/path/to/dir --output backup.zip

# Compress specific files in external directory, output there
$ uv run zippa pack file1.txt file2.py --chdir ~/path/to/dir --output backup.zip

Case 3: Compress items from external directory, output in different directory

# Compress everything in external directory, output elsewhere
$ uv run zippa pack . --chdir ~/path/to/source --output ~/path/to/output/backup.zip

# Compress specific files in external directory, output elsewhere
$ uv run zippa pack file1.txt file2.py --chdir ~/path/to/source --output ~/path/to/output/backup.zip

Exclude Patterns

# Exclude specific patterns via command line
$ uv run zippa pack . --exclude "*.pyc" --exclude "__pycache__" --exclude "*.log"

# Use custom .zipignore file
$ uv run zippa pack . --exclude-file .myignore

# Combine .zipignore with additional exclusions
$ uv run zippa pack . --exclude-file .zipignore --exclude "*.tmp"

# Exclude patterns with external directory
$ uv run zippa pack . --chdir ~/path/to/project --exclude "*.pyc" --exclude "__pycache__"

.zipignore File

Create a .zipignore file in your project root to define default exclusions:

# .zipignore example
*.pyc
__pycache__/
*.log
*.tmp
.git/
node_modules/
.env
*.DS_Store
build/
dist/
*.egg-info/

Additional Options

# Verbose output
$ uv run zippa pack . --output backup.zip --verbose

# Custom compression level
$ uv run zippa pack . --compress-level 6 --output backup.zip

# Show help
$ uv run zippa --help
$ uv run zippa pack --help

Important Notes

  • Case 1: Items are relative to your current working directory
  • Case 2 & 3: Items are relative to the directory specified by --chdir
  • Output location: Can be anywhere (absolute or relative path)
  • Current limitation: --chdir must come after the items to compress

Future Updates

  • listen to events and compress correspondently
  • implement extraction of compressed items
  • implement compression summary after each compression

Author

Carlos Pumar-Frohberg

🤝 Support

Comments, questions and/or feedback are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zippa-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zippa-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file zippa-0.1.0.tar.gz.

File metadata

  • Download URL: zippa-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for zippa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e0dac3de127f50f308722bfc4b0c04ab9c822fc174ea71b4895ce1ebf138e4b
MD5 7a74b11429bb3e6d9842e60aa048a81b
BLAKE2b-256 8a6a02034af6a27c7ef4121599679ea0154d5bf96dfb4b9811cbb6f8a7602b59

See more details on using hashes here.

File details

Details for the file zippa-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zippa-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for zippa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f93e882166998379543792f37bb40c8020b879e5b98e1a7484da4d969427430
MD5 d03a86dcd2b61d9d9cac5539503b7d12
BLAKE2b-256 0338f20a4749443d258a2e6a053d6026ab81f12f627a3dee887048d18a84509e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page