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 #

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-00019.spk

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:
      • Attempts to read EXIF DateTimeOriginal from top-level tags
      • If not found, searches nested EXIF data (ExifIFD) for DateTimeOriginal
      • Falls back to DateTimeDigitized if DateTimeOriginal is unavailable
      • Uses sophisticated multi-level EXIF parsing to handle different camera formats
    • 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): Reads DateTimeOriginal from top-level tags, then nested EXIF data (ExifIFD), with fallback to DateTimeDigitized. Supports both modern and legacy Pillow methods for maximum camera compatibility.
  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 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 #

Note: Log file names were changed in v1.0.1-00017 for clarity.

Log Format Details #

File Operation Log Format #

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

Updated in v1.0.1-00017:

System/Application Log Format #

Each entry in Photo_Organizer_Application.log contains:

Updated in v1.0.1-00017:

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.