Safety: - clean no longer deletes a dated file whose content is missing from the store. os.SameFile(nil, ...) returned false, so clean removed the file and then failed to relink it. MissingLink now reports and skips those files, and Relink swaps the link in with link+rename, so the path exists the whole time. - Move writes the content file under a temporary name, checks it against the hash, fsyncs it, and links it into place. An interrupted run can no longer leave a truncated file that later runs treat as a dup. - The crawl logs and skips unreadable paths instead of stopping, and it ignores AppleDouble ._ files and QNAP .@__thumb directories. Features: - sha256 content addresses by default; -hash=md5 adds to older stores. - am verify rehashes the store and reports corrupt, orphaned, and stale temp files. It only reads. - -n dry run for arr and clean prints the plan as TSV and changes nothing. - arr ends with a summary of counts and sizes by extension and year, with no file names. - heic/heif/avif, tiff, dng, cr2/cr3, nef, and arw are dated by exif via imagemeta, with goexif kept as the jpeg fallback. Exif times without an offset are read as local time, as before. - mov/mp4/m4v/3gp are dated from the moov/mvhd creation time. mkv, mts, webm, and friends are now included and dated by mtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.2 KiB
Markdown
37 lines
1.2 KiB
Markdown
# arrange
|
|
|
|
de-duplicate and arrange photos and movies into a content-addressed store,
|
|
with hardlinks by date.
|
|
|
|
out/content/ab/cdef….jpg one copy of each file, named by its sha256
|
|
out/date/2006/03/1143508767….jpg hardlinks to those, by capture time
|
|
|
|
Capture time comes from exif (jpeg, heic, camera raw), the QuickTime movie
|
|
header (mov, mp4, m4v, 3gp), or the file's mtime as a last resort.
|
|
|
|
## usage
|
|
|
|
go install mcquay.me/arrange/cmd/am@latest
|
|
|
|
# see what would happen; prints new/dup<TAB>src<TAB>content<TAB>date dir
|
|
am arr -n ~/Pictures /mnt/store > plan.tsv
|
|
|
|
# do it; nothing in the source is changed
|
|
am arr ~/Pictures /mnt/store
|
|
|
|
# re-hash the store: corrupt files, orphans, leftovers from crashed runs
|
|
am verify /mnt/store
|
|
|
|
# turn dated files that are copies rather than hardlinks back into links
|
|
am clean -n /mnt/store
|
|
am clean /mnt/store
|
|
|
|
# print the time and path am would use for some files
|
|
am meta a.jpg b.mov
|
|
|
|
`arr` ends with a summary of counts and sizes by extension and year. It
|
|
names no files, so it is safe to share.
|
|
|
|
Stores made before sha256 use md5 names; add to one with `-hash=md5`.
|
|
`verify` works out the hash from each name's length.
|