Photo / video organizer and deduplicator implemented in Python 3, for ARMv7 devices
10K+
Docker image hosting a photo / video organizer and deduplicator implemented in Python 3, for ARM / x86 / x64 devices.
Main features :
Detailed features for organizer :
/storage
└── 2021 # [Year]
└── 2021-07 # [Year]-[Month]
└── 20210716_175913-001.jpg # [Year][Month][Day]_[Hour][Min][Sec][-XXX].[ext]
# [-XXX] suffix for files with same date/time
Detailed features for deduplicator :
Other features :
docker logs pyphotorg (or in Portainer web UI)services:
# ==========================================================================
# pyphotorg
pyphotorg:
image: ahuh/pyphotorg:latest
container_name: pyphotorg
environment:
# Operation switches
- ENABLE_ORGANIZE=true
- ENABLE_DEDUPLICATE=true
# Dry-run mode (no modification applied) or real mode
- DRY_RUN_MODE=false
# Job scheduler (cron format)
- "SCHEDULE_CRON=15 2 * * sun"
# Web app (no authentication; expose only on a trusted network)
- WEB_PORT=8080
# Deduplicator - Dirs and priority orders for duplicate removal (remove duplicates from highest to lowest number)
- "DEDUP_STORAGE_PATH=/storage/Photos"
- "DEDUP_BACKUP_PATH=/storage/Backup/pyphotorg"
- "DEDUP_DIR_ORDER_01=/storage/Photos/Family"
- "DEDUP_DIR_ORDER_02=/storage/Photos/Friends"
- "DEDUP_DIR_ORDER_03=/storage/Photos/Mobile-A"
- "DEDUP_DIR_ORDER_04=/storage/Photos/Mobile-B"
- "DEDUP_DIR_PATH_FILTER=/.@__thumb"
# Organizer - Path couples: sync dirs (source) and storage dirs (target)
- "ORG_INCOMING_PATH_01=/storage/sync/camera-a"
- "ORG_STORAGE_PATH_01=/storage/Photos/Mobile-A"
- "ORG_INCOMING_PATH_02=/storage/sync/camera-b"
- "ORG_STORAGE_PATH_02=/storage/Photos/Mobile-B"
# Organizer parameters
- ORG_TIMESTAMP_TAGS=FileModifyDate,CreationDate,CreateDate,DateTimeOriginal
- ORG_STORAGE_PATH_PATTERN=%Y/%Y-%m/%Y%m%d_%H%M%S%%-3c.%%e
# Persistent deduplication cache
- DEDUP_CACHE_PATH=/cache/dedup_hashes.sqlite3
# User from docker host to impersonate in container
- PUID=500
- PGID=1000
volumes:
- pyphotorg-cache:/cache
- /etc/localtime:/etc/localtime:ro
# Sync dir
- /share/homes/XXX/.Qsync:/storage/sync
# Storage dir
- /share/Perso/Photos:/storage/Photos
# Backup dir
- /share/Perso/Backup/pyphotorg:/storage/Backup/pyphotorg
ports:
- "8080:8080"
restart: always
volumes:
pyphotorg-cache:
The named pyphotorg-cache volume survives container restarts and image upgrades. Do not remove it with docker compose down -v unless you also want to discard the cached hashes.
Before running container, you have to retrieve UID and GID for the user used to mount your tv shows directory:
$ id -u <user>
$ id -g <user>
The container will run impersonated as this user, in order to have read/write access to volume directories.
You also need to create volume directories before launching the container with the same user rights.
| Env var name | Default value | Description |
|---|---|---|
| ENABLE_ORGANIZE | true | If enable, organize operation is launch at the beginning of each job execution |
| ENABLE_DEDUPLICATE | true | If enable, deduplicate operation is launch at the end of each job execution |
| DRY_RUN_MODE | false | In dry-run mode, photo / video files are not modified or move : only reports and logs are generated |
| SCHEDULE_CRON | 0 2 * * sun | Schedule for job execution in format min hour day_of_month month day_of_week. See http://en.wikipedia.org/wiki/Cron for details |
| DEDUP_STORAGE_PATH | Storage directory containing photo / videos files to process, during deduplication operation | |
| DEDUP_BACKUP_PATH | Backup directory to use, during deduplication operation. Each duplicate file removed is backed-up in this directory (with the same directory structure as the original). An Excel report is alse generated here at each execution (if duplicate files detected) | |
| DEDUP_DIR_ORDER_XX | OPTIONAL - Multiple variables supported (XX=01, 02, etc). Directory priority orders for duplicate removal (remove duplicates from highest to lowest number) | |
| DEDUP_DIR_PATH_FILTER | OPTIONAL - Paths containing this literal string are skipped during the directory scan, before files are inspected. E.g. "/.@__thumb" for QNAP NAS thumbnail directories generated automatically | |
| DEDUP_CACHE_PATH | /cache/dedup_hashes.sqlite3 | SQLite file used to persist deduplication hashes. Keep /cache on a Docker volume to reuse hashes after container replacement. |
| ORG_INCOMING_PATH_XX | Multiple variables supported (XX=01, 02, etc). List of incoming directory (source) for move / organize operation. Each value is coupled with the corresponding storage directory value (same XX index). If no variable used: the storage dir is used as source and target ('in-place' organize) | |
| ORG_STORAGE_PATH_XX | Multiple variables supported (XX=01, 02, etc). List of storage directory (target) for move / organize operation. Each value is coupled with the corresponding incoming directory value (same XX index) | |
| ORG_TIMESTAMP_TAGS | FileModifyDate,CreationDate,CreateDate,DateTimeOriginal | List of metadata to use in reverse order of priority for path / filename insertion, during move / organize operation. See documentation here: https://exiftool.org/filename.html#ex12 |
| ORG_STORAGE_PATH_PATTERN | %Y/%Y-%m/%Y%m%d_%H%M%S%%-3c.%%e | Relative path to target dir (base path = ORG_STORAGE_PATH_XX) and target filenames, during organize operation. See documentation here: https://exiftool.org/filename.html#codes |
| PUID | User UID to use for job impersonation | |
| PGID | User GID to use for job impersonation | |
| WEB_PORT | 8080 | Port used by the lightweight web app |
With the container running, open http://<NAS address>:8080. The page shows the next scheduled execution, allows a manual job to be started with phase/file-hashing progress, and provides a cache-clean button with a confirmation prompt. Only one job or cache-clean operation can run at a time.
The web app has no authentication. Do not expose port 8080 to the public internet; restrict access to a trusted network.
In addition to the scheduled jobs, each operation may be launched manually. These commands are available in docker container using docker exec -ti pyphotorg bash (or in Portainer web UI)
$ ./scripts/execPy.sh /work/manual_organize.py -h
$ ./scripts/execPy.sh /work/manual_deduplicate.py -h
$ ./scripts/execPy.sh /work/manual_clean_cache.py
Each script has a command-line help available with arg -h, explaining how to set parameters.
You may also execute the scheduled job manually:
$ ./scripts/execPy.sh /work/manual_job.py
From the repository root, create a Python 3.14 environment and install the test dependencies:
uv venv --python 3.14 .venv
source .venv/bin/activate
uv pip install pandas croniter pause openpyxl
Note: the Docker image installs pandas from Alpine's py3-pandas package instead of pip to avoid a slow ARM build.
Run the unit and deduplication tests:
cd pyphotorg
python -m unittest discover -s tests -v
Build (for current arch):
$ ./docker-build.sh
Push (for current arch):
$ ./docker-push.sh
Or with buildx (build & push multiarch):
$ ./docker-buildx.sh [--no-cache]
Pass --no-cache to prune all cache from an existing multiarch-builder before removing it and starting the build with a fresh builder.
WARNINGS:
docker buildx does not work in QNAP NAS: install and execute in WSL insteadbuildkitd.toml configuration to limit BuildKit parallelism to 4 operationsdocker pull ahuh/pyphotorg:latest