A collection of practical command-line tools and automation scripts for everyday tasks. These tools demonstrate file operations, system automation, data processing, and productivity enhancements.
This repository showcases:
- Command-line argument parsing with argparse
- File system operations and automation
- Text processing and data manipulation
- System utilities and productivity tools
- Error handling and logging
Difficulty: Beginner
Concepts: File operations, os module, shutil, directory management
Automatically organize files in a directory by type, date, or custom rules.
Features:
- Organize by file extension
- Organize by creation/modification date
- Undo last organization
- Dry-run mode to preview changes
- Custom folder naming rules
Usage: python file_organizer.py <directory> [options]
Difficulty: Beginner
Concepts: Regex, file operations, batch processing
Rename multiple files at once using patterns, regex, or sequential numbering.
Features:
- Pattern-based renaming
- Regex support
- Sequential numbering
- Case conversion
- Preview mode
- Undo functionality
Usage: python bulk_renamer.py <directory> [options]
Difficulty: Intermediate
Concepts: Hashing, file comparison, optimization
Find and manage duplicate files based on content (MD5/SHA256 hashing).
Features:
- Multiple hash algorithms
- Size-based pre-filtering
- Interactive deletion
- Move duplicates to folder
- Generate duplicate report
- Safe mode with confirmation
Usage: python duplicate_finder.py <directory> [options]
Difficulty: Intermediate
Concepts: Text parsing, regex, data analysis, reporting
Parse and analyze log files to extract insights and generate reports.
Features:
- Extract error patterns
- Count log levels (INFO, WARNING, ERROR)
- Time-based analysis
- Export statistics to CSV/JSON
- Filter by date range
- Generate visualizations
Usage: python log_analyzer.py <logfile> [options]
Difficulty: Intermediate
Concepts: Image manipulation, batch processing, Pillow library
Process multiple images at once: resize, convert, compress, watermark.
Features:
- Resize images (maintain aspect ratio)
- Format conversion (PNG, JPG, WebP)
- Compression with quality control
- Add watermarks
- Batch processing
- Progress indicators
Usage: python image_processor.py <input_dir> [options]
Difficulty: Advanced
Concepts: System information, psutil, monitoring, alerts
Monitor system resources (CPU, Memory, Disk) and send alerts.
Features:
- Real-time CPU/Memory monitoring
- Disk usage tracking
- Process listing
- Alert thresholds
- Export logs
- Dashboard view
Usage: python system_monitor.py [options]
Python 3.8 or higher- Clone the repository:
git clone https://github.com/b5119/python-cli-tools.git
cd python-cli-tools- Install dependencies:
pip install -r requirements.txt# Organize downloads folder
python 01-file-organizer/organizer.py ~/Downloads --by-type
# Rename photos sequentially
python 02-bulk-renamer/renamer.py ./photos --pattern "vacation_{num}" --start 1
# Find duplicate files
python 03-duplicate-finder/finder.py ~/Documents --delete
# Analyze web server logs
python 04-log-analyzer/analyzer.py access.log --errors-only
# Resize all images to 800px width
python 05-image-processor/processor.py ./images --resize 800
# Monitor system with alerts
python 06-system-monitor/monitor.py --alert-cpu 80 --alert-memory 90Pillow>=10.0.0
psutil>=5.9.0
colorama>=0.4.6
tqdm>=4.65.0
Install all dependencies:
pip install -r requirements.txtpython-cli-tools/
βββ README.md
βββ requirements.txt
βββ 01-file-organizer/
β βββ organizer.py
βββ 02-bulk-renamer/
β βββ renamer.py
βββ 03-duplicate-finder/
β βββ finder.py
βββ 04-log-analyzer/
β βββ analyzer.py
βββ 05-image-processor/
β βββ processor.py
βββ 06-system-monitor/
βββ monitor.py
- Argparse: Building robust CLI interfaces
- File Operations: Reading, writing, moving, copying files
- Path Handling: Using pathlib for cross-platform compatibility
- Error Handling: Try-except blocks, logging
- Performance: Efficient file processing
- User Experience: Progress bars, colored output
- System Programming: Interacting with OS
Most tools support these common flags:
--help, -h- Show help message--verbose, -v- Verbose output--dry-run- Preview changes without executing--recursive, -r- Process subdirectories--output, -o- Specify output location
- Always use --dry-run first to preview changes
- Backup important files before bulk operations
- Use absolute paths to avoid confusion
- Check permissions before file operations
- Read the help with
--helpflag
# Run with elevated permissions (use cautiously)
sudo python script.py [args]# Reinstall dependencies
pip install -r requirements.txt --upgrade# Use absolute paths
python script.py /full/path/to/directoryContributions are welcome! Ideas for new tools:
- PDF merger/splitter
- Text file diff tool
- Backup automation script
- Database backup tool
- Git automation utilities
This project is licensed under the MIT License.
Frank Bwalya- https://github.com/b5119
- Python standard library documentation
- Pillow (PIL) documentation
- psutil documentation
β Star this repository if you find it useful!
| Tool | Difficulty | Primary Use | Dependencies |
|---|---|---|---|
| File Organizer | β Beginner | Clean messy directories | Built-in only |
| Bulk Renamer | β Beginner | Rename multiple files | Built-in only |
| Duplicate Finder | ββ Intermediate | Free up disk space | Built-in only |
| Log Analyzer | ββ Intermediate | Debug applications | Built-in only |
| Image Processor | ββ Intermediate | Batch image editing | Pillow |
| System Monitor | βββ Advanced | System health checks | psutil |