A robust Python CLI utility for automating monthly photo organization from Apple Photos exports.
- Smart File Processing: Converts HEIC files to high-quality JPEG with EXIF preservation
- Intelligent Organization: Separates files into photos, videos, screenshots, and generated content
- Timestamp-Based Renaming: Uses EXIF/metadata timestamps (YYYY.MM.DD.HH.MM.SS format)
- Video Metadata Extraction: Extracts creation dates from video file metadata (MOV, MP4, etc.)
- AI Content Detection: Automatically identifies and separates AI-generated images and heavily edited photos
- Screenshot Recognition: Detects iOS screenshots with pattern matching
- Automatic Cleanup: Removes Apple sidecar (.aae) files
- Duplicate Handling: Intelligently resolves timestamp conflicts
- Rich CLI Experience: Beautiful progress bars, colored output, and detailed summaries
- Dry-Run Mode: Safe testing without file modifications
- Comprehensive Logging: Detailed error handling and processing reports
- Python 3.8+
- macOS (tested), Linux (should work), Windows (untested)
- Clone the repository:
git clone https://github.com/tommcfarlin/tm-monthly-backup.git
cd tm-monthly-backup- Create and activate a virtual environment (recommended):
python3 -m venv tm-backup-env
source tm-backup-env/bin/activate # On Windows: tm-backup-env\Scripts\activate- Install dependencies:
pip install -r requirements.txtclick>=8.0.0- CLI interface frameworkpillow>=10.0.0- Image processing and EXIF data extractionpillow-heif>=0.10.0- HEIC file format supportpython-dateutil>=2.8.0- Advanced date/time parsingrich>=13.0.0- Beautiful CLI progress bars and formattinghachoir>=3.1.0- Video metadata extraction
- Export photos from iCloud Photos to the
export/directory - Run the backup utility:
# Dry run (recommended first)
python -m src.main --dry-run
# Process files with progress display
python -m src.main
# Verbose output for debugging
python -m src.main --verbose
# View help and options
python -m src.main --helptm-monthly-backup/
├── export/ # Place exported iCloud files here
├── backup/ # Organized output files
│ ├── photos/ # Real photos with EXIF timestamps
│ ├── videos/ # Videos with metadata timestamps
│ ├── screenshots/ # iOS screenshots and screen captures
│ ├── generated/ # AI-generated and heavily edited content
│ └── unknown/ # Unrecognized file types (if any)
├── src/ # Source code
├── tests/ # Test suite
└── docs/ # Documentation
Automatically detects and separates AI-generated images:
- C2PA Metadata: Files with ChatGPT, GPT-4o, or OpenAI signatures
- UUID Filenames: 36-character UUID-format names (often generated content)
- Editing Software: Files processed by editing software without original EXIF data
Extracts real creation dates from video metadata:
- MOV, MP4, M4V: Uses embedded creation timestamps
- Screen Recordings: Handles screen capture metadata
- Fallback Handling: Uses filesystem dates when metadata unavailable
Identifies iOS and macOS screenshots:
- Filename Patterns:
IMG_3XXX.PNG,Screenshot,Screen Shot - iOS Patterns: Recognizes standard iOS screenshot naming
- HEIC files: Converted to JPEG (lossless) with EXIF preservation
- Apple sidecar files (.aae): Deleted automatically
- Naming convention: Files renamed using EXIF/metadata timestamps (YYYY.MM.DD.HH.MM.SS)
- Video metadata: Extracts creation timestamps from video file headers
- Duplicate handling: Timestamp conflicts resolved by incrementing seconds
- AI content separation: Generated and heavily edited content goes to dedicated folder
- Missing metadata: Fallback to filesystem timestamps with user warnings
The project includes a comprehensive test suite covering unit tests and integration tests.
python tests/run_tests.py# Unit tests only
python tests/run_tests.py --unit-only
# Integration tests only
python tests/run_tests.py --integration-onlySee tests/README.md for detailed testing documentation.
- CLI Usage Guide - Complete command-line reference
- Troubleshooting Guide - Solutions for common issues
- Development Workflow - Contribution guidelines
- Test Documentation - Test suite information
See docs/development-workflow.md for contribution guidelines.
MIT License - see LICENSE file for details.
See CHANGELOG.md for version history.