Fractional seconds in date format (%f) uses old filename instead

Started by Moonbase59, April 11, 2022, 06:55:17 AM

Previous topic - Next topic

Moonbase59

Using exiftool 12.30-1 on Manjaro Linux 21.2.5, and using %f within the date field produces the old filename instead of fractional seconds, as stated in the docs.

My file a.jpg has the following date info:

exiftool -time:all -G1 -a -s a.jpg
[System]        FileModifyDate                  : 2011:04:28 17:34:10+02:00
[System]        FileAccessDate                  : 2022:04:08 18:51:23+02:00
[System]        FileInodeChangeDate             : 2022:04:11 12:42:50+02:00
[IFD0]          ModifyDate                      : 2011:04:28 15:34:09
[ExifIFD]       DateTimeOriginal                : 2011:04:28 15:34:09
[ExifIFD]       CreateDate                      : 2011:04:28 15:34:09
[ExifIFD]       SubSecTime                      : 83
[ExifIFD]       SubSecTimeOriginal              : 83
[ExifIFD]       SubSecTimeDigitized             : 83
[Composite]     SubSecCreateDate                : 2011:04:28 15:34:09.83
[Composite]     SubSecDateTimeOriginal          : 2011:04:28 15:34:09.83
[Composite]     SubSecModifyDate                : 2011:04:28 15:34:09.83


I then do a

exiftool -P -d '%Y%m%d-%H%M%S%f' '-FileName<${SubSecCreateDate}-${Model}%-c.%le' a.jpg

expecting a new filename of
20110428-153409.83-Canon EOS 1000D.jpg
but instead get
20110428-153409a-Canon EOS 1000D.jpg

Error on my side or a bug?

(The docs state to use the exiftool date extension %f for fractional seconds, and %%f for the old filename.)

Would really love to see this working reliably, to get the correct image sequences for exposure series and action photography.

StarGeek

Quote from: Moonbase59 on April 11, 2022, 06:55:17 AM
Using exiftool 12.30-1

From the version history page
     Version 12.35
     Added %f code to -d option for fractional seconds


Update your version if you want to use %f.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Moonbase59

Thanks for the heads-up! Same page says

QuoteNote: The most recent production release is Version 12.30. (Other versions are considered development releases, and are not uploaded to MetaCPAN.)

So maybe that is the reason 12.30 ist the latest Manjaro offers. Any idea when the next "stable" will arrive?

In the meantime, I'll try to manually update.

Moonbase59

Just in case other Linux users are interested, here is my little exifrename bash script that has a number of fallbacks for the date and auto-adjusts for the use of sub-second date strings (by checking the installed exiftool version).

Target filename format: YYYYMMDD-HHMMSS.sss-camera.ext, leaving out elements that don't exist (sub-seconds, camera model).


#!/bin/bash

# exifrename

# 2022-04-11 Matthias C. Hormann (aka Moonbase59)

# rename image and video files from original date taken, with fallbacks
#   exifrename [file, folder, params]
# where [params] are standard exiftool parameters, i.e. '-ext jpg'

# Format (in sequence of fallbacks):
#   YYYYMMDD-HHMMSS.sss-camera.ext
#   YYYYMMDD-HHMMSS.sss.ext
#   YYYYMMDD-HHMMSS-camera.ext
#   YYYYMMDD-HHMMSS.ext
#   YYYYMMDD-HHMMSS.ext (taken from file system's modify date if no tags in file)
#
# The filename extension will always be lowercased, for ease of use, i.e. .JPG -> .jpg
#
# In case of duplicate files, a copy number in the form of '-#' will be added
# to the file name, for all formats shown above, i.e.
#   YYYYMMDD-HHMMSS.ss-camera-#.ext

# define me
me=$(basename "$0")

# check if exiftool installed
command -v exiftool >/dev/null 2>&1 || { echo >&2 "$me requires \"exiftool\" but it's not installed. Aborting."; exit 2; }

# check if we can use sub-second dates
# (Versions 12.35 and above added %f code to -d option for fractional seconds)
REQVERSION="12.35"
CURVERSION="$(exiftool -ver)"
if [ ! "$(printf '%s\n' "$REQVERSION" "$CURVERSION" | sort -V | head -n1)" = "$REQVERSION" ]; then
  echo >&2 "Sub-second dates only available in \"exiftool\" version $REQVERSION or newer."
  echo >&2 "You have version $CURVERSION, adjusting for full-second precision."
  DATESTRING='%Y%m%d-%H%M%S'
else
  DATESTRING='%Y%m%d-%H%M%S%3f'
fi

# If it exists, we prefer DateTimeOriginal over the composite tag CreateDate,
# because some cameras store nonsense here (OnePlus One has create date 2002:12:08 12:00:00
# and stores no model name).

# We use the Metadata Working Group (MWG) composite tags here, to allow
# certain overlapping EXIF, IPTC and XMP tags to be reconciled when reading,
# and synchronized when writing.
# These also use SubSecond dates, if available.
# See https://exiftool.org/TagNames/MWG.html

exiftool -P -d "$DATESTRING" \
  '-FileName<${FileModifyDate}%-c.%le' \
  '-FileName<${MWG:CreateDate}%-c.%le' \
  '-FileName<${MWG:CreateDate}-${Model}%-c.%le' \
  '-FileName<${MWG:DateTimeOriginal}%-c.%le' \
  '-FileName<${MWG:DateTimeOriginal}-${Model}%-c.%le' \
  $@


Phil Harvey

Quote from: Moonbase59 on April 11, 2022, 11:49:00 AM
Any idea when the next "stable" will arrive?

No current schedule.  Probably within a couple of months.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Moonbase59

Thanks. For the time being, I succeeded to uninstall the provided versions on my Manjaro and Linux Mint systems, and installed 12.41 according to your instructions in the docs.

Runs fine so far.