One-click backup, effortless restoration! Batch7z is a command-line tool designed for developers, making batch compression and extraction simpler and more efficient than ever.
✨ Key Features:
- 🚀 Blazing Fast Compression: Based on LZMA2 algorithm with up to 70% compression ratio, significantly saving storage space
- 📁 Smart Packaging: Automatically identifies subdirectories and files, intelligently excludes already-compressed formats and temporary files
- 🔒 Flexible Encryption: Supports no password or custom passwords to meet different security requirements
- 🌍 Cross-Platform Support: Provides both Bash and PowerShell versions, perfectly compatible with Windows/macOS/Linux
- 🎯 Precise Control: Supports directory level stripping (strip) and force overwrite, flexible for various scenarios
💡 Use Cases:
- Quick project backup and migration
- Batch packaging of server deployment packages
- Multi-version project archive management
- One-click backup and restore of development environments
- batch7z: Batch compress first-level subdirectories under the target directory into .7z archives
- batchun7z: Batch extract .7z format archives, supports directory level stripping (strip) and force overwrite
- High compression ratio (LZMA2 algorithm)
- Automatically filters unnecessary files (*.log, .DS_Store, node_modules, etc.)
- Supports optional password setting for compression/extraction
macOS:
brew install p7zip
Linux:
# Debian/Ubuntu sudo apt-get install p7zip-full # Arch Linux sudo pacman -S p7zip
Windows:
- Download and install 7-Zip: https://www.7-zip.org/
macOS:
brew install p7zip
pwsh # Install PowerShellLinux:
# Install p7zip sudo apt-get install p7zip-full # Debian/Ubuntu sudo pacman -S p7zip # Arch Linux # Install PowerShell # Refer to official documentation: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell
📖 Detailed Guide: See PowerShell Version Usage Guide
# Clone or download scripts git clone <repository-url> cd batch7z # Install dependencies brew install p7zip # macOS # or sudo apt-get install p7zip-full # Linux # Add execute permissions chmod +x batch7z batchun7z # Start using ./batch7z -d /path/to/project ./batchun7z -d /path/to/restore
# Windows # Download and install 7-Zip: https://www.7-zip.org/ .\batch7z.ps1 -d "C:\path\to\project" .\batchun7z.ps1 -d "C:\path\to\restore" # macOS/Linux # Install p7zip and PowerShell brew install p7zip pwsh # Run scripts pwsh -File ./batch7z.ps1 -d "/path/to/project" pwsh -File ./batchun7z.ps1 -d "/path/to/restore"
Batch compress first-level subdirectories under the target directory into .7z archives.
Basic Usage:
batch7z # Compress all subdirectories in current directory batch7z -d /path/to/dir # Compress specified directory batch7z -p 123456 # Use custom password batch7z -f # Force re-compression (overwrite existing archives) batch7z -h # Show help information
Usage Examples:
- Backup all subdirectories of current project:
cd /Volumes/work/wwwroot
batch7z- Compress specified directory and set password:
batch7z -d ~/Desktop/projects -p mypassword- Force re-compression (overwrite existing archives):
batch7z --force # Using long option # or batch7z -f # Using short option
- Compress multiple deployment packages for easy transfer:
cd /var/www/vhosts
batch7z -p deploy2026Configuration Notes:
- Compression format: .7z (compatible with WinRAR, BetterZip, 7-Zip, etc.)
- Compression algorithm: LZMA2 (xz)
- Auto-filter:
*.log,*.tmp,.DS_Store,node_modules/,.next/ - Already compressed formats (not packaged): .7z, .rar, .gz, .zip, .tar, .iso, .dmg, etc.
- File naming:
- Subdirectories:
subdirectory_name_YYYY-MM-DD_HH-MM.7z - Files:
current_directory_name_files_YYYY-MM-DD_HH-MM.7z
- Subdirectories:
- Default password: No password (optional to set)
- Force mode: Skip existing archives by default, use
-for--forceto force overwrite
Batch extract all .7z format archives in current directory, supports directory stripping and force overwrite.
Basic Usage:
batchun7z # Extract all archives in current directory batchun7z -d /path/to/dir # Extract to specified directory batchun7z -p 123456 # Use custom password batchun7z -s 2 # Strip first 2 directory levels batchun7z -f # Force overwrite existing files batchun7z -h # Show help information
Usage Examples:
- Restore all backup packages in current directory:
cd /Volumes/work/wwwroot
batchun7z- Extract to specified directory and set password:
batchun7z -d ~/Desktop/restore -p mypassword- Strip nested directory structure:
# Archive contents: a/b/c/app/index.js # After using -s 2: app/index.js batchun7z -s 2
- Force overwrite updates (skip existing files):
batchun7z -f
Configuration Notes:
- Supported formats: .7z (only archives generated by batch7z)
- Strip feature: Strip first N directory levels of files in the archive
- Default behavior: Skip existing files, no directory stripping
- Default password: No password (optional to set)
- Scan first-level subdirectories under target directory
- Create independent .7z archive for each subdirectory
- Apply file filtering rules (exclude logs, temporary files, etc.)
- Use LZMA2 algorithm for high-ratio compression
- Optionally set password protection for archives
- Generate filenames with timestamps
- Package non-compressed files in current directory (exclude already compressed formats)
- Scan all .7z files in current directory
- Verify password and extract to temporary directory
- Strip specified directory levels based on strip setting
- Handle existing files based on overwrite setting
- Clean up temporary directory, complete extraction
- Ensure 7z command is properly installed and added to PATH
- Recommend testing with small batch of data before large-scale operations
- Use quotes when password contains special characters
- Strip feature modifies directory structure, use with caution
- Default no password, use -p parameter if encryption is needed
- Current directory file packaging automatically excludes already compressed formats
| File | Platform | Description |
|---|---|---|
batch7z |
macOS/Linux | Bash version batch compression tool |
batchun7z |
macOS/Linux | Bash version batch extraction tool |
batch7z.ps1 |
Windows/macOS/Linux | PowerShell version batch compression tool |
batchun7z.ps1 |
Windows/macOS/Linux | PowerShell version batch extraction tool |
README.md |
- | Project documentation |
README_CN.md |
- | Chinese version project documentation |
docs/POWERSELL_USAGE.md |
- | PowerShell version detailed usage guide |
| Feature | Bash Version | PowerShell Version |
|---|---|---|
| Runtime Environment | macOS/Linux | Windows / macOS / Linux |
| Command Format | ./batch7z |
.\batch7z.ps1 or pwsh -File ./batch7z.ps1 |
| Feature Set | Identical | Identical |
| Configuration Parameters | Identical | Identical |
| Cross-Platform | Unix systems only | All platforms |
| Recommended Use Cases | macOS/Linux development environments | Windows development environments or cross-platform needs |
# Backup entire project directory (including all subdirectories and files) cd ~/projects/myproject ./batch7z -p "backup2026" # Generates: # - app_2026年01月16日_14-30.7z # - lib_2026年01月16日_14-30.7z # - myproject_files_2026年01月16日_14-30.7z (contains README.md, package.json, etc.)
cd /var/www/vhosts ./batch7z -p "deploy2026" # Each site is independently packaged for easy distribution to different servers
# Package on macOS ./batch7z -d ~/Documents/projects -p "migrate" # Extract on Windows .\batchun7z.ps1 -d "C:\Projects\Restore" -p "migrate"
# Archive contents: project/src/2025/backup/app/index.js # After using -s 3: app/index.js ./batchun7z -s 3
Issues and improvement suggestions are welcome!
This project's tools are for personal use only.