Photo Organizer and Deduplicator

Synology DSM 7 Package #

Photo Organizer Icon

Table of Contents #

  1. Overview
  2. Package Details
  3. GitHub Repository
  4. Download
  5. File Processing Logic
  6. Duplicate Handling
  7. Statistics Tracking
  8. Logging
  9. Synology Integration
  10. License
  11. Support

Overview #

Photo Organizer and Deduplicator is a Synology NAS package that automatically organizes and manages your photo collection. The application continuously monitors a designated folder and automatically sorts photos by their capture date, detects duplicates, and organizes your entire photo library with minimal user intervention.

Key Features #

Recent Highlights #

🔴 Critical Fixes in Latest Versions:

  • v1.0.1-00019: Fixed critical statistics tracking bug - statistics now update immediately after file moves, ensuring 100% accuracy even if logging fails
  • v1.0.1-00018: Fixed EXIF date extraction priority - photos now organized by actual capture date (nested ExifIFD tags) instead of file modification date

✨ Major Improvements:

  • Persistent Statistics: JSON-based statistics tracking that persists across restarts (Photo_Organizer_Statistics.json)
  • Enhanced Date Detection: Added CreateDate tag support and fixed priority order to use actual photo capture dates
  • Improved Logging: Enhanced log entries with destination format information for better traceability

Package Details #

Package Information #

Technical Requirements #

Installation #

  1. Download the .spk file (see download link below)
  2. Open Synology Package Center
  3. Click “Manual Install” and select the downloaded .spk file
  4. Follow the installation wizard
  5. Configure the source and destination directories during setup

Usage #

Once installed, the service runs automatically in the background:

  1. Place photos in the configured source directory (default: Photos/Photo Organizer)
  2. The service automatically processes existing photos
  3. New photos added to the folder are automatically organized
  4. Photos are sorted into year-based folders with consistent naming
  5. Duplicates are detected and handled according to the configured settings

GitHub Repository #

View on GitHub

The project source code, build scripts, and documentation are available on GitHub. Contributions, bug reports, and feature requests are welcome!

Download #

Latest Version: #

Download PhotoOrganizer-1.0.1-00029.spk

Recent Updates:

File Processing Logic #

The Photo Organizer uses a file system watcher to monitor the source directory and processes each file through the following workflow:

Processing Workflow #

  1. File Detection: The system waits 0.5 seconds after detecting a new file to ensure it’s fully written (important for large files being copied)

  2. File Type Detection: Determines if the file is an image or video based on file extension

  3. Date Extraction (in priority order):

    • Images:
      • Priority 1: Nested ExifIFD DateTimeOriginal (tag 0x9003) - HIGHEST PRIORITY - Most accurate capture date
      • Priority 2: Nested ExifIFD DateTimeDigitized (tag 0x9004)
      • Priority 3: Nested ExifIFD CreateDate (Added in v1.0.1-00018)
      • Priority 4: Top-level DateTimeOriginal
      • Priority 5: Top-level DateTimeDigitized
      • Priority 6: Top-level CreateDate (Added in v1.0.1-00018)
      • Priority 7: Top-level DateTime (tag 0x0132) - LOWEST PRIORITY - File modification date
      • Uses sophisticated multi-level EXIF parsing to handle different camera formats
      • 🔴 Critical Fix (v1.0.1-00018): Nested ExifIFD tags are now correctly prioritized over top-level tags. This ensures actual photo capture date is used instead of file modification date. Previously, the script incorrectly checked top-level DateTime (file modification date) before nested DateTimeOriginal (actual capture date).

    • Videos: Attempts to read creation date from video metadata (MP4/MOV using mutagen library)
    • Fallback: Uses the older of file creation or modification timestamp (newer might have modifications)
  4. Destination Path Generation:

    • If date found: Creates path YYYY/MM_Mmm/ (e.g., 2024/08_Aug/)
    • Filename format: yyyymmdd_hhmmss.ext (without subseconds for destination folder)
    • If no date found: Moves to NoDateFound/ folder with original filename
  5. Duplicate Check: Before moving, checks if a file with the same name already exists at the destination:

    • Size Comparison: First compares file sizes (fast optimization)
    • MD5 Hash Check: If sizes match, compares MD5 hashes
    • Exact Duplicate: If hashes match, handles according to DELETE_DUPLICATES setting
    • Different Content: If hashes differ, compares modification times and keeps older file
  6. File Movement: Moves the file to the appropriate destination folder:

    • Files are renamed to consistent yyyymmdd_hhmmss.ext format when date is available
    • Original filenames preserved for files without date information
    • Duplicates are handled according to the configured strategy

Date Extraction Methods #

The application uses multiple methods to extract date information in priority order:

  1. EXIF Metadata (Images):
    • Nested ExifIFD tags (highest priority): Reads DateTimeOriginal, DateTimeDigitized, and CreateDate from nested ExifIFD structure (tag 0x8769)
    • Top-level tags (fallback): Reads DateTimeOriginal, DateTimeDigitized, CreateDate, and DateTime from top-level EXIF tags
    • Priority order ensures actual photo capture date is used: Nested ExifIFD tags contain the most accurate capture metadata and are checked first
    • Supports both modern and legacy Pillow methods for maximum camera compatibility
    • 🔴 Critical Fix (v1.0.1-00018): Fixed incorrect priority order that was using file modification date before actual capture date. Now correctly prioritizes nested ExifIFD tags (actual capture date) over top-level tags (file modification date). Added support for CreateDate tag in both nested and top-level EXIF structures.

  2. Video Metadata: Reads creation date from MP4/MOV metadata using mutagen library, supporting ISO 8601 format.
  3. File Timestamps: Uses the older of creation or modification time, preserving sub-second precision when available.

Duplicate Handling #

The application uses MD5 hash comparison for duplicate detection, with file size comparison first for performance optimization.

Handling Strategies #

Filename Formats #

Before moving a file to the Duplicates folder, the system checks if an identical file (same MD5 hash) already exists there. If found, the current file is deleted instead of creating another duplicate, ensuring efficient storage usage.

Statistics Tracking #

The application maintains statistics about file operations, tracking files/bytes moved to destination folders, moved to Duplicates, and deleted (duplicates). Statistics are stored persistently in Photo_Organizer_Statistics.json, automatically loaded on startup, and adjusted when files move between destination and Duplicates folders.

Statistics Accuracy #

🔴 Critical Fix (v1.0.1-00019): Statistics are now updated immediately after file move operations complete, ensuring all files are accurately counted even if logging or indexer operations fail. This guarantees data integrity: if a file is moved, it’s always counted in statistics.

What Changed:

  • Statistics update moved to execute immediately after shutil.move() succeeds
  • Logging and indexer updates are wrapped in separate try-except blocks
  • Non-critical operation failures (logging, indexer) no longer prevent statistics updates
  • Applied to all file move operations: normal organization, unknown file types, and file replacements

Statistics Data #

The Photo_Organizer_Statistics.json file tracks:

Statistics Persistence #

Statistics are automatically logged when:

Logged format: Info, System, YYYY/MM/DD HH:MM:SS, PhotoOrganizer, Statistics (reason): X.XX GB moved, X.XX MB deleted

Logging #

The application uses multiple logging methods for reliability: system logger (accessible via DSM Log Center), Synology-specific logging, and package log files stored in the destination directory.

Log Files #

  1. Photo_Organizer_Activities.log - Detailed file operation log

    • Tracks all file operations, moves, deletions, and duplicate handling
    • Format: Log, Time, IP address, User, Event, File/Folder, File size, File name, Additional Info
  2. Photo_Organizer_Application.log - System and application events log

    • Records service start/stop, dependency checks, and system-level events
    • Format: Level, Log, Time, User, Event (Info, Warning, Error)
  3. Photo_Organizer_Statistics.json - Persistent statistics file (see Statistics Tracking section)

Logged Events #

File Operations: File detected, file moved (with rename info), duplicate deleted, moved to duplicates (with reason), file moved/renamed, errors

System Events: Service started/stopped, dependency checks, statistics (see Statistics Tracking section)

Viewing Logs #

Log Format Details #

File Operation Log Format #

Each entry in Photo_Organizer_Activities.log contains (in order):

Updated in v1.0.1-00017:

  • Improved event descriptions for moved/deleted files, including statistics adjustments.
  • Some operations may log both old and new destination paths when moving between destination and duplicates folders.
  • Moved files from destination to duplicates folder will decrease destination stats and increase duplicates stats (see Photo_Organizer_Statistics.json).

System/Application Log Format #

Each entry in Photo_Organizer_Application.log contains:

Synology Integration #

The Photo Organizer is specifically designed to integrate seamlessly with Synology DiskStation Manager (DSM), providing native NAS functionality.

Synology Detection #

The application automatically detects if it’s running on a Synology NAS by checking:

Photo Indexer Integration #

The application automatically updates Synology’s photo indexer (synoindex) after file operations: removes deleted files from index (synoindex -D), updates index when files are moved (removes old path, adds new path), and silently handles cases where indexer is unavailable. This ensures Photo Station stays synchronized with file organization.

Configuration #

License #

Copyright (c) 2025 MORCE.codes

This package provides automatic photo organization functionality for Synology NAS. The Photo Organizer and Deduplicator application is provided as-is for organizing photos based on EXIF metadata.

Support #

For issues, questions, or contributions, please visit the GitHub repository


Note: This package is designed specifically for Synology DiskStation Manager (DSM) and requires a Synology NAS running DSM 7.0 or later.