24 releases (9 breaking)

new 0.17.8 Sep 5, 2024
0.17.6 Aug 3, 2024
0.17.5 Jul 25, 2024

#754 in Command line utilities

Download history 256/week @ 2024-06-27 967/week @ 2024-07-04 303/week @ 2024-07-11 5/week @ 2024-07-18 232/week @ 2024-07-25 148/week @ 2024-08-01 8/week @ 2024-08-08 2/week @ 2024-08-15 104/week @ 2024-08-29

119 downloads per month

Custom license

36KB
816 lines

phorg

Idempotent photo/video file organizer.

test status dependencies status

Overview

Given a <src> and <dst> directories:

  1. finds photo/video files in <src>
  2. fetches their Exif data
  3. computes their hash digests
  4. moves/copies them into <dst>/{<img>,<vid>}/<year>/<month>/<day>/<date>--<time>--<digest>[.<ext>] where:
    • <img> and <vid> default to "img" and "vid", respectively, and are customizable via CLI
    • date and time are extracted from Exif metadata, from whichever of the following tags is found first, tried in order:
      • DateTimeOriginal
      • CreationDate
      • DateTimeCreated
      • CreateDate
      • DateCreated
      • Datecreate
      • TrackCreateDate
  5. optionally, you can (manually) add semantically-named subdirectories underneath the <day> directory and (manually) move the media files into them, these subdirectories will then be preserved on subsequent reprocessings, i.e. when this <dst> is later used as <src>

Example

(note the semantic subdirectory on 2020-11-29)

$ phorg /mnt/usb-drive $dst move
$ cd $dst
$ tree .
.
├── img
   ├── 2020
   │   ├── 11
   │   │   ├── 29
   │   │   │   └── Hike on Suffern-Bear Mountain Trail
   │   │   │       ├── 2020-11-29--15:23:10--crc32:c7d15ddf.heic
   │   │   │       ├── 2020-11-29--15:29:40--crc32:b4f4e4e0.heic
   │   │   │       ├── 2020-11-29--15:30:07--crc32:3b5aa617.heic
   │   │   │       └── 2020-11-29--15:38:30--crc32:514c9b0c.heic
   │   │   └── 30
   │   │       ├── 2020-11-30--08:20:00--crc32:08a5aa4a.heic
   │   │       ├── 2020-11-30--08:23:41--crc32:bba07552.heic
   │   │       ├── 2020-11-30--08:24:24--crc32:94c0f155.heic

Install

  1. Ensure a Rust 1.75.0+ toolchain is installed: https://www.rust-lang.org/tools/install
  2. cargo install phorg
  3. Ensure ~/.cargo/bin/ is in your PATH
  4. phorg help

Dependencies

Hard

Only the Rust tools mentioned above, everything else will be handled by cargo.

Soft

exiftool, which is used as a fallback whenever we fail to extract the needed metadata ourselves. This fallback can be disabled via CLI.

Absence of exiftool in PATH will cause errors which will be logged, but will not disrupt execution and the files we could not read enough data about will just be skipped.

Dependencies

~16–27MB
~388K SLoC