fix/photorenamer-review #1

Merged
ludovic.terrier merged 5 commits from fix/photorenamer-review into master 2026-11-10 20:27:49 +01:00
Owner
No description provided.
The script passed an unquoted filename through eval, split paths on
colons and newlines, and printed DRY-RUN after a failed write while
counting the file as processed. Build argv arrays, walk files with
find -print0, read MIME type, model, software and date in one exiftool
call per file, and report failures per file without aborting the run.
Split policy into model_code and plan_rename so tests can source the
script. Drop dead flags (-f, -o, -v), noclobber, and the unused FIFO.
A tab-separated read merged empty Software or Model values and shifted
CreateDate, so valid files were skipped silently. Use a "|" separator.
Empty files and .DS_Store no longer count as failures, a read failure on
a real file logs the exiftool reason, a find failure now fails the run,
a dash-leading -s path works, and a JPEG without an extension is skipped
instead of renamed to a name with a trailing dot. Burst numbering stays
invisible in a dry run; the usage text now says so.
A "|" or a newline in Model or Software shifted the fields, so Lightroom
and DxO files were renamed and files with a date were skipped. CreateDate
now comes second and the two free-text tags come last with "|" and line
breaks replaced inside the exiftool -p format. This keeps one exiftool
call per file, where per-tag calls would triple the cost. A rename that
exiftool answers with "No writable tags set", or a dry run with no
output, now counts as failed with the reason logged. The unknown-model
message names the file, and the temp file is removed on exit, INT and TERM.
A "|" or line break in CreateDate still shifted the fields, so a
Lightroom file was renamed; sanitize it like the other tags. exiftool
turns out-of-range dates into other dates without complaint (month 13,
hour 25, "2019:05"), so check the ranges first and skip with a message
naming the file. A zero or blank date, written by cameras with an unset
clock, is a no-create-date skip instead of a failed rename.

The already-processed regex stays anchored on purpose: only exact
processed names are skipped, so "x2019-11-28_223516_p3.jpg" is renamed,
unlike the unanchored original.
exiftool turns 2019:02:30, second 60 and similar dates into other dates
with no warning, and it fails on year 0000 or 9999. Validate the full
date in bash: days per month with leap years, seconds 00-59, years
1900-2099. After the seconds only subseconds and Z or +-HH:MM (HH up to
14) are accepted, so free text no longer passes. The timezone and
subsecond tests now assert the exact new name. The trap is set before
mktemp so an early signal cannot leak the temp file.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ludovic.terrier/scripts!1
No description provided.