Skip to main content

A simple tool to archive photos

Project description

photoarchive

A simple tool to copy all unique photos to an archive

Background

I often backup phones and cameras, but to different places, using no consistent naming conventions, and more importantly, with no check for duplicates. This tool takes such a backup location and copies all image files to a better structured archive, excluding duplicates and renaming unique files with duplicate file names.

Usage

Select a place where you will put your archive. Make sure that your source files will have unique paths (i.e. if you have a bunch of usb sticks that would all be called "D:", copy the files to a hard drive first).

pip install photoarchive
cd <archivefolder>
python -mphotoarchive <sourcefolder>

Alternative

git clone https://github.com/roseeng/photoarchive
cd photoarchive
python __main__.py <sourcefolder>

Notes of interest

Uniqueness

Files to be copied are checked against the files in the existing archive using the following logic:

  • Are the file names similar? If they do, go to next check, if not, copy.
  • Do they have the exact same size? If they do, go to next check, if not, copy.
  • Do they have the same MD5 checksum? If they do, mark as duplicate, if not, copy.

All treated files are added to a list, so you can run the command against the exact same folder and only working on new files. This is saved in treatedfiles.txt. All copied files are added to a dictionary, with file size and hash value, to avoid recomputation. This is saved in filedict.json.

Name comparison

The logic for "similar names" are as follows:

  • If file suffix is different, the files are different. Else remove suffix from comparison.
  • Take the first 5 chars
  • From the remainder, remove all digits
  • From the result, remove underscores and parenthesis.

The aim is to make files like "DSC4711.jpg" and "DSC4711(1).jpg" similar, but "47122.jpg" and "47123.jpg" different. In a future version, this should be tweakable. It is not the end of the world if it's not perfect though, the result is just more fstat() calls and hash calculations.

Archive structure

When copying a file, we try to get the original date from the EXIF information. If that does not succeed, we take the creation date of the file.

That is then used to build the folder structure in the archive as: Bilder/YYYY/MM/DD. The files keep the old name in that folder, optionally with "-n" added if there already is a file with the same name in the folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

photoarchive-0.5.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

photoarchive-0.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file photoarchive-0.5.tar.gz.

File metadata

  • Download URL: photoarchive-0.5.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for photoarchive-0.5.tar.gz
Algorithm Hash digest
SHA256 7bdc23cbde3a7b16808b4d4215dcb763ee1703b60961f3e61b629cb12cdf4b78
MD5 2e798a18664f8a6f6dae99faa06881b1
BLAKE2b-256 26c10baa364ff2a2fb97fc473221f89bab8f5343ab3ccdc64fc0e4242f2d0eed

See more details on using hashes here.

File details

Details for the file photoarchive-0.5-py3-none-any.whl.

File metadata

  • Download URL: photoarchive-0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for photoarchive-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c2b44be9393aa6f444d7ea82a0e3f8ea5b3ad18d4f3aa906101e4ba8fd7cff5a
MD5 35fe6be03de6c24e4f9cf04cd70ecc74
BLAKE2b-256 6e2fa20c8f735ba0fb1cae01d6c591c2adc5e0cbe266b908a6c52295b62a8cec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page