Collection of Python scripts for automating everyday tasks including file organization, backups, email sending, and web scraping.
- π File Organizer - Automatically organize files by type and extension
- πΎ Backup Manager - Create and manage incremental backups
- π§ Email Sender - Bulk email sending with personalization
- π Web Scraper - Extract data from websites easily
- π οΈ Utility Helpers - Common helper functions for all tools
- Clone the repository:
git clone https://github.com/maxxunit1/python-automation-tools.git
cd python-automation-tools- Install dependencies:
pip install -r requirements.txt- Python 3.7+
- See
requirements.txtfor package dependencies
Automatically organize files in a directory by their type and extension.
Usage:
python file_organizer.py --path /path/to/directoryOptions:
--path- Directory to organize (required)--dry-run- Preview changes without moving files--undo- Undo previous organization--verbose- Enable detailed logging
Supported File Types:
- Images: jpg, png, gif, svg, webp, ico
- Documents: pdf, doc, docx, txt, xlsx, pptx
- Videos: mp4, avi, mkv, mov, webm
- Audio: mp3, wav, flac, aac, ogg
- Archives: zip, rar, 7z, tar, gz
- Code: py, js, html, css, java, cpp
- And many more...
Examples:
# Preview organization
python file_organizer.py --path ~/Downloads --dry-run
# Organize files
python file_organizer.py --path ~/Downloads
# Undo organization
python file_organizer.py --path ~/Downloads --undoCreate and manage file and directory backups with incremental support.
Usage:
python backup_manager.py --source /path/to/source --dest /path/to/backupsOptions:
--source- Source path to backup (required)--dest- Destination for backups (required)--incremental- Create incremental backup (only changed files)--list- List all available backups
Features:
- Full and incremental backups
- Automatic timestamping
- Easy restore functionality
- Conflict resolution
Examples:
# Create full backup
python backup_manager.py --source ~/Documents --dest ~/Backups
# Create incremental backup
python backup_manager.py --source ~/Documents --dest ~/Backups --incremental
# List all backups
python backup_manager.py --source ~/Documents --dest ~/Backups --listSend bulk emails with personalization support via SMTP.
Usage:
from email_sender import EmailSender
sender = EmailSender(
smtp_server='smtp.gmail.com',
smtp_port=587,
username='your-email@gmail.com',
password='your-password'
)
# Send single email
sender.send_email(
to_addresses=['recipient@example.com'],
subject='Hello',
body='Email body here'
)
# Send bulk emails with personalization
recipients = [
{'email': 'user1@example.com', 'name': 'John'},
{'email': 'user2@example.com', 'name': 'Jane'}
]
template = "Hello {name}, this is a personalized email!"
sender.send_bulk_emails(recipients, 'Subject', template)Features:
- SMTP support (Gmail, Outlook, custom servers)
- HTML email support
- Bulk sending with personalization
- Error handling and retry logic
Extract data from websites using BeautifulSoup.
Usage:
from web_scraper import WebScraper
scraper = WebScraper('https://example.com', delay=1.0)
# Fetch and parse page
soup = scraper.fetch_page('https://example.com/page')
# Extract specific data
data = scraper.extract_data(
'https://example.com',
{
'titles': 'h1, h2',
'paragraphs': 'p',
'links': 'a'
}
)
# Save to JSON
scraper.save_to_json(data, 'output.json')Features:
- Automatic rate limiting
- CSS selector support
- JSON export
- Session management
- User-agent rotation
The utils package provides common helper functions:
from utils import format_bytes, ensure_directory, get_file_hash
# Format file size
size = format_bytes(1024000) # "1.00 MB"
# Ensure directory exists
path = ensure_directory('data/output')
# Calculate file hash
hash_value = get_file_hash('file.txt', algorithm='sha256')requests>=2.28.0
beautifulsoup4>=4.11.0
python-dotenv>=1.0.0
pytest>=7.2.0
colorama>=0.4.6Create a .env file for sensitive configuration:
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
EMAIL_USERNAME=your-email@gmail.com
EMAIL_PASSWORD=your-app-passwordFor Gmail, you need to:
- Enable 2-factor authentication
- Generate an App Password
- Use the App Password in your configuration
# 1. Preview what will happen
python file_organizer.py --path ~/Downloads --dry-run
# 2. Organize files
python file_organizer.py --path ~/Downloads
# 3. If needed, undo
python file_organizer.py --path ~/Downloads --undo# Daily backup
python backup_manager.py --source ~/Projects --dest ~/Backups --incremental
# Weekly full backup
python backup_manager.py --source ~/Projects --dest ~/BackupsRun tests with pytest:
pytestRun specific test:
pytest tests/test_file_organizer.pyContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the Python community for excellent libraries
- BeautifulSoup for web scraping
- Colorama for terminal colors
Project Link: https://github.com/maxxunit1/python-automation-tools
Made with β€οΈ for automation enthusiasts
"""Documentation updated"""
"""Documentation updated"""
async def async_operation(): """Async operation support""" result = await fetch_data() return process(result)