Files
homelab-configs/owncloud/README.md
T

1.9 KiB

ownCloud Photo Organizer

Overview

ownCloud's Android app does not support automatic year/month subfolder creation during instant upload (unlike Nextcloud). This script compensates by running nightly and sorting all uploaded photos and videos into a YEAR/YEAR-MM/ folder structure.

Script

Location on server: /usr/local/bin/organize_photos.sh

Source folder watched: /mnt/INTEL-SSD/ownCloud - Joe Gitta@cloud.jgitta.com/Personal/InstantUpload

Subfolders processed: Camera, BlueIris, Facebook, scans, EufyVideoDir

Supported file types: jpg, jpeg, png, gif, heic, webp, bmp, tiff, mp4, mov, pdf

How It Works

The script reads the date from each filename using these patterns (in order):

  1. YYYYMMDD embedded in the filename (e.g. 20231022_082107.jpg)
  2. YYYY-MM-DD or YYYY_MM_DD format
  3. 13-digit Unix timestamp in milliseconds (e.g. FB_IMG_1572815868839.jpg)
  4. MM_DD_YYYY prefix (scans folder format, e.g. 06_11_2026_7_28_16_AM.pdf)

Files that don't match any pattern are moved to _unsorted/ for manual review.

Output Structure

InstantUpload/
└── Camera/
    ├── 2023/
    │   ├── 2023-06/
    │   └── 2023-12/
    ├── 2024/
    │   └── 2024-03/
    └── _unsorted/

Cron Job

Runs nightly at 2:00 AM as root:

0 2 * * * /usr/local/bin/organize_photos.sh

To view or edit: sudo crontab -e

Log File

Each run appends to /var/log/organize_photos.log:

=== 2026-06-14 02:00:01 Starting ===
  Moved: 12  Unsorted: 0  Skipped: 0  Errors: 0
=== Done ===

Check the log anytime with:

cat /var/log/organize_photos.log

Installation

sudo cp organize_photos.sh /usr/local/bin/organize_photos.sh
sudo chmod +x /usr/local/bin/organize_photos.sh
(sudo crontab -l; echo "0 2 * * * /usr/local/bin/organize_photos.sh") | sudo crontab -