Skip to main content

photosorter

PyPI version number Supported Python version License Test Coverage Download Count

A little Python script to keep my photos from Dropbox organized. Designed to be run intermittently, but will run forever by default.

It watches a source directory for modifications and moves new image files to a target directory depending on when the photo was taken, using EXIF data and creation date as a fallback. There is also an option to move existing photos.

Directory and file names follow a simple naming convention (YYYY-MM/YYY_MM_DD/YYYY-MM-DD hh:mm:ss.ext) that keeps everything neatly organized. Duplicates are detected and ignored based on their SHA1 hash and folder path. Photos taken in the same instant get de-duplicated by adding a suffix (-1, -2, etc) to their filenames.

The result looks somewhat like this:

├── 2013-01
│   ├── 2013_01_05
│   │   ├── 2013-01-05 13.24.45.jpg
│   │   ├── 2013-01-05 14.25.54.jpg
│   │   └── 2013-01-05 21.28.48-1.jpg
│   ├── 2013_01_06
│   │   ├── 2013-01-06 16.05.02.jpg
│   │   ├── 2013-01-06 19.59.25.jpg
│   │   ├── 2013-01-06 20.40.28.jpg
│   │   └── 2013-01-06 21.14.38.jpg
│   └── 2013_01_08
│       └── 2013-01-08 11.45.51.jpg
├── 2013-02
|   └─ ...
├── ...
├── 2013-12
├── 2014-01
├── 2014-02
├── ...
├── 2014-12
├── ...

I use C:\Users\[windows username]\Dropbox\Camera Uploads as the source directory and Z:\Photos as the target. This allows me to move my photo from Dropbox to a local drive, and merge them with the rest of my photo collection.

Inspired by

Installation

The easiest way to install the script is through pip:

> pip install minchin.scripts.photosorter

Requirements

The script’s requirements will be automatically installed in the script is installed via pip as recommended above. They can also be installed manually, if required:

pip install argcomplete>=1.3.0
pip install ExifRead>=2.1.2
pip install watchdog>=0.8.3

Usage

Watch src_dir and sort incoming photos into dest_dir:

> photosorter src_dir dest_dir

When you’re done with it, Ctrl + C will end the program.

If you also want to move the existing files in src_dir (which are, by default, ignored):

> photosorter src_dir dest_dir --move-existing

Run on System Startup

  1. Move photosorter.conf.example to /etc/init as photosorter.conf and edit it to suit your needs by replacing the user, source and target directories.

  2. Run $ sudo start photosorter.

  3. Check the logs at /var/log/upstart/photosorter.log.

Known Issues

  • the tests do not currently run.

  • matching (to provide de-duplication) is based on full filepaths matching. I.e. if the folder is renamed, the script will not look in the renamed folder for photo matches.

  • Linux deamon setup is untested by myself.

Changes

Unreleased

  • fix update support script, so it actually updates our requirements

  • move automated testing from Travis-CI to Github Actions

2.1.0 – 2017-08-28

  • also move MP4 files

  • add changelog to readme

2.0.0 – 2017-08-27

  • move to minchin.scripts.photosorter namespace

  • do releases via minchin.releaser

  • changed generated file folder layout

  • add option to move existing files

Meta

Distributed under the MIT license. See LICENSE.txt for more information.

https://github.com/MinchinWeb/minchin.scripts.photosorter

Metadata

Release files for minchin.scripts.photosorter 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minchin.scripts.photosorter 2.2.0
File Size Uploaded
minchin_scripts_photosorter-2.2.0.tar.gz 5.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for minchin.scripts.photosorter 2.2.0
File Interpreter ABI Platform
minchin_scripts_photosorter-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 MB

Release files / minchin_scripts_photosorter-2.2.0.tar.gz

Download URL minchin_scripts_photosorter-2.2.0.tar.gz
Size 5.9 MB
Tags Source
SHA-256 checksum
How to use checksums
5b6bf8f8c69b0c5a87d2963834fa569e80bf49b9a09eddbcbfbd4d1d48af4aee
BLAKE2b-256 checksum
How to use checksums
273a534f9dac1abe11a4b2b0b342832472ff240200b2121afa25dd9d28fbe246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / minchin_scripts_photosorter-2.2.0-py3-none-any.whl

Download URL minchin_scripts_photosorter-2.2.0-py3-none-any.whl
Size 5.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e071318e809170a88210ee21d9d92a9cadb7a81836ca9b8ab5ac421cf0592c24
BLAKE2b-256 checksum
How to use checksums
41435c86f61660a47b546d50b1beef542d3b9a4e41873d993e467b4b915982f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page