Giter Site home page Giter Site logo

mso1830 / syn-photo-sort Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jrlucier/syn-photo-sort

0.0 0.0 0.0 7 KB

This python script will automatically bucket photos in a destination folder based on date, specifically built for Synology NAS's running DSM given the unique constraints on the system.

License: Other

Python 100.00%

syn-photo-sort's Introduction

Intro

This script will bucket photos from a given source directory into a dated tree structure in a destination directory.

This script was written to run on a Synology NAS with DiskStation on board (python 2.7, and exiv2 installed).
The idea being I wanted all backed up photos (using either DS Photo or DS File) to get automatically moved, sorted, and structured by date using their EXIF date and time. If no EXIF date and time are found, it falls back to using the file systems "last modified" date and time. It also handles duplicates by checking for MD5 collisions if matching timestamps are found. If there aren't duplicates and just so happen to be unique photos taken at that exact same date and time, it will add a counter on to the end of the filename (look at the example below with the -0001) to prevent conflicts.

The destination structure looks like he following:

Dest/
  2015/
    02/
      02FEB2015/
        20150202-183511.jpg
        20150202-183511-0001.jpg
        20150202-193501.jpg

Usage

These are the program arguments:

usage: syn_photo_sort.py [-h] [-m] source destination type

required arguments:
  source       The source directory to read image/video files from.
  destination  The destination directory to put image/video files, renamed and
               with the proper folder structure
  type         The type of files to move. Specify one: photo, video

optional arguments:
  -h, --help   show this help message and exit
  -m, --move   Specify to move source files to their new location instead of

The source directory is scanned recursively, for whatever kind of file you specified via the type flag of "photo" or "video". The types and extensions are as follows:

  • photo: '.JPG', '.PNG', '.THM', '.CR2', '.NEF', '.DNG', '.RAW', '.NEF', '.JPEG'
  • video: '.3PG', '.MOV', '.MPG', '.MPEG', '.AVI', '.3GPP', '.MP4'

If you specify the -m or --move flag, it will move the source file to its intended destination and delete it from the source directory. It will also clean up any existing empty folders that might exist. It will however leave the root source directory.

Setup For Synology NAS

SCP the file up, and place it at /usr/local/bin/syn_photo_sort (no need for the .py extension). You should now be able to call it at any time using syn_photo_sort. Once there, setup your cron job by using DSM and visiting the "Task Scheduler". Create a new user user defined script and place all the command line calls you want to run. Such as:

syn_photo_sort -m /data/source /data/destination photo

syn-photo-sort's People

Contributors

jrlucier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.