Organize photos, videos, and audio files by EXIF/ID3 creation date
Project description
EXIF Sorter
Organize photos, videos, and audio recordings into date-based folders using EXIF/QuickTime/ID3 metadata. Designed for managing large media collections efficiently using concurrent processing.
Performance: Using 24 cores with a local NAS, 18,000 files (~175 GB) processed in about 8 minutes.
Why This Package?
I created this out of my own need to organize media from GoPros, Canon cameras, and iPhones into a YYYY-MM-DD folder structure—the same format used by legacy photo organization apps from Canon and others. This structure allows for quick storage by day and handles multiple files and naming conventions cleanly.
When I couldn't find an existing package that did this well, I built my own. It started as a macOS Automator macro and evolved into this pip package as requirements grew: better video support, audio recordings, configurable date formats, day-start boundaries for event photography, and date range filtering.
Philosophy: This package is intentionally lean. It serves one function—sorting media by date—and does it well and quickly. No feature creep.
Quick Start (Docker)
The easiest way to use exif-sorter—no installation required:
docker run --rm -v /path/to/unsorted:/input -v /path/to/sorted:/output davidamacey/exif-sorter sort /input /output
More examples:
# Sort media files (expanded for readability)
docker run --rm -v /path/to/unsorted:/input -v /path/to/sorted:/output \
davidamacey/exif-sorter sort /input /output
# Dry run (preview changes)
docker run --rm -v /path/to/media:/input -v /path/to/sorted:/output \
davidamacey/exif-sorter sort /input /output --dry-run
# Copy instead of move
docker run --rm -v /path/to/unsorted:/input -v /path/to/sorted:/output \
davidamacey/exif-sorter sort /input /output --copy
# Remove duplicates
docker run --rm -v /path/to/sorted:/data \
davidamacey/exif-sorter dedup /data
# Show help
docker run --rm davidamacey/exif-sorter --help
Installation (pip)
Prerequisites
- Python 3.11+
exiftoolsystem package
# Install exiftool (Ubuntu/Debian)
sudo apt install exiftool
# Install exiftool (macOS)
brew install exiftool
# Install exiftool (Windows via Chocolatey)
choco install exiftool
# Or via Scoop
scoop install exiftool
Install Package
# Install from PyPI
pip install exif-sorter
# Or clone and install in development mode
git clone https://github.com/davidamacey/exif-sorter.git
cd exif-sorter
pip install -e .
Usage
After installation, the exif-sorter command is available with three subcommands:
Sort Media Files
Organize media into date-based folders by reading EXIF metadata:
# Basic usage - sort and MOVE files (default)
exif-sorter sort /path/to/unsorted/ /path/to/sorted/
# Copy instead of move (keeps originals)
exif-sorter sort /path/to/unsorted/ /path/to/sorted/ --copy
# Dry run - preview without changes
exif-sorter sort /path/to/unsorted/ /path/to/sorted/ --dry-run
Advanced options:
# Custom folder format (default: %Y-%m-%d)
exif-sorter sort /source/ /dest/ --format "%Y/%m" # 2023/12/
exif-sorter sort /source/ /dest/ --format "%Y/%B" # 2023/December/
exif-sorter sort /source/ /dest/ --format "%Y-%m-%d" # 2023-12-25 (default)
# Day begins at 4am (2am photos go to previous day - useful for events)
exif-sorter sort /source/ /dest/ --day-begins 4
# Filter by date range
exif-sorter sort /source/ /dest/ --from-date 2023-01-01 --to-date 2023-12-31
Default behavior:
- Moves files (removes from source after successful transfer)
- Creates
00_no_date_found/for files without date metadata - Creates
00_media_error/for files that fail processing - Falls back to filename date patterns (e.g.,
IMG_20231225_143022.jpg) - Auto-generates log file:
sort_YYYY-MM-DD.log - Removes empty source folders after sorting
Remove Duplicate Files
Find and remove duplicates within each subdirectory using fast imohash:
# Remove duplicates (keeps file with shortest name)
exif-sorter dedup /path/to/sorted/
# Dry run - see what would be removed
exif-sorter dedup /path/to/sorted/ --dry-run
Clean .DS_Store Files
Remove macOS .DS_Store files from a directory tree:
exif-sorter clean /path/to/directory/
Workflow
Typical workflow for importing photos from iPhone or camera.
Using Docker (recommended):
# 1. Sort imported media by date
docker run --rm -v ~/import:/input -v ~/Pictures:/output \
davidamacey/exif-sorter sort /input /output
# 2. Clean up macOS artifacts
docker run --rm -v ~/Pictures:/data davidamacey/exif-sorter clean /data
# 3. Remove any duplicates within date folders
docker run --rm -v ~/Pictures:/data davidamacey/exif-sorter dedup /data
Using pip:
# 1. Sort imported media by date
exif-sorter sort ~/import/ ~/Pictures/
# 2. Clean up macOS artifacts
exif-sorter clean ~/Pictures/
# 3. Remove any duplicates within date folders
exif-sorter dedup ~/Pictures/
iPhone Import Instructions
Connect iPhone to Linux
- Connect iPhone via USB
- Turn off WiFi and Bluetooth, turn on Personal Hotspot
- In Files app, navigate to Network section
- Remove the
:3/from the address to connect to iPhone system
Copy Files
- Navigate to iPhone DCIM folder
- Select folders to copy
- Drag and drop to your import folder (e.g.,
~/import/) - Run the sort workflow above
Date Extraction Priority
The sorter checks these metadata sources in order:
| Priority | File Types | Metadata Tag | Notes |
|---|---|---|---|
| 1 | Videos (MP4, MOV, M4V) | QuickTime:CreationDate |
Has timezone - correct local date |
| 2 | Videos (MP4, MOV, M4V) | QuickTime:CreateDate |
Fallback, may be UTC |
| 3 | Photos (JPEG, PNG, HEIC, RAW) | EXIF:DateTimeOriginal |
|
| 4 | Photos (JPEG, PNG, HEIC, RAW) | EXIF:CreateDate |
|
| 5 | Audio (MP3) | ID3:RecordingTime |
ID3v2.4 TDRC tag |
| 6 | Audio (MP3) | ID3:Year |
Year only |
| 7 | Audio (WAV) | RIFF:DateTimeOriginal |
IDIT chunk |
| 8 | Audio (WAV) | RIFF:DateCreated |
ICRD chunk |
| 9 | All files | File:FileModifyDate |
Universal fallback |
| 10 | All files | Filename patterns | e.g., IMG_20231225_143022.jpg |
Notes:
- Audio (M4A, AAC) uses QuickTime tags (same as videos)
.AAEsidecar files only useFile:FileModifyDate
Duplicate Detection
Duplicates are detected using imohash, a fast hashing algorithm optimized for large files. Instead of reading entire files, imohash samples ~16KB from the beginning, middle, and end of files along with the file size.
Benefits:
- Extremely fast for large media files (videos, RAW photos)
- Suitable for detecting true duplicates (same file copied multiple times)
Limitations:
- May produce false positives for files that differ only in the middle sections (rare for media)
- Not suitable for detecting near-duplicates or edited versions of the same photo
- Files must be exactly the same size and have identical sampled sections to match
For most photo/video organization workflows where duplicates are exact copies, imohash provides an excellent speed/accuracy tradeoff.
Project Structure
exif-sorter/
├── src/exif_sorter/ # Main package
│ ├── cli.py # CLI entry point
│ ├── sorter.py # MediaFileSorter class
│ └── utils/ # Utility modules
│ ├── dsstore.py # DS_Store removal
│ ├── duplicates.py # Duplicate detection (imohash)
│ └── exif.py # EXIF/ID3/RIFF date extraction
├── Dockerfile # Docker image definition
├── pyproject.toml # Package configuration
├── CHANGELOG.md # Version history
└── README.md # This file
Acknowledgments
This project is built on ExifTool by Phil Harvey—the gold standard for reading and writing metadata in media files. ExifTool's comprehensive support for EXIF, IPTC, XMP, QuickTime, ID3, and hundreds of other metadata formats makes this package possible.
- ExifTool: https://exiftool.org/
- PyExifTool: Python wrapper used by this package
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exif_sorter-1.1.0.tar.gz.
File metadata
- Download URL: exif_sorter-1.1.0.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50b02a1e86eec1b2b99edf7fabedc386b3a263d12d22cd4228dcfed706e15f57
|
|
| MD5 |
71db44955ff4b11fe3fff9e8eb6fa173
|
|
| BLAKE2b-256 |
08e1766f4d6aa29f470aef4ae2fcdf1a68598c843efcf7ee1e1f4940cb071556
|
File details
Details for the file exif_sorter-1.1.0-py3-none-any.whl.
File metadata
- Download URL: exif_sorter-1.1.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56360c80bef7dad5426d6a37508b2b805994804efebf128c79cf557032fab6c4
|
|
| MD5 |
9bb39647bc0ccccda3a0c52da72782a0
|
|
| BLAKE2b-256 |
2585e2c5c4d529c4037e77fa8add9d2e4dbd360582ea3214c6d27c4af438eb71
|