Metadata-Version: 2.4
Name: ibatch
Version: 0.5.0
Summary: 
Author: David Polák
Author-email: David Polák <email@davidpolak.cz>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: click>=8.3.1
Requires-Dist: geopy>=2.4.1
Requires-Dist: pyexiftool>=0.5.6
Requires-Python: >=3.13, <4
Description-Content-Type: text/markdown

# ibatch
Does things to photos

## Timestamps

`ibatch timestamp DIR` sets each file's modification time to the moment it was
shot. For photos the exact moment is worked out in this order:

1. an offset embedded in the date (XMP, e.g. `2024:07:01 07:54:26-05:00`);
2. the EXIF offset tag belonging to the date: `OffsetTimeOriginal` for
   `DateTimeOriginal`, `OffsetTimeDigitized` for `CreateDate`; `OffsetTime`
   only if `ModifyDate` equals the capture time (otherwise it describes an
   edit);
3. the offset implied by the GPS time: the capture wall clock minus the GPS
   UTC time, rounded to 15 minutes. It is used only if the rounding leaves less
   than 2 minutes over, and if it is within 3 hours of the longitude's solar
   time (longitude / 15), which rules out most stale GPS fixes;
4. otherwise the machine's timezone is assumed. The command ends with a note
   counting such photos.

`rename` always uses the wall-clock time as shot, whatever the timezone.
`--dry-run` previews the result, including the offset that was used.

Limits of the GPS step: it cannot tell a fresh fix from an old one, as long as
the result looks like a real offset near the photo's longitude. A fix taken an
hour before a photo in Prague gives `+03:00` instead of `+02:00`, silently, and
near the date line a fix a day old can be a whole day off. Prefer the offset
tags; the GPS step is a best effort.

### Videos

Videos are not converted. Their time is `Keys:CreationDate` if present (its
offset is dropped and the wall clock kept), otherwise the UTC `CreateDate`
shown in `Keys:AndroidTimeZone` if present, otherwise in the machine's timezone.
Either way the wall clock is then read in the machine's timezone, so a video's
modification time is right only if the machine is in the zone where it was
shot.

### Files that fail

A photo that cannot be read, or a file that cannot be touched or renamed, is
reported and the rest are still processed. `timestamp` and `rename` then exit
with an error and count it as failed (`--dry-run` too, for an unreadable
photo). `geo` only warns about an unreadable photo and leaves it out. An
unreadable video is warned about and counted as skipped, with exit status 0.
