patch to read track and disk numbers as integers when total number is unknown

Started by dae65, July 24, 2020, 11:02:02 AM

Previous topic - Next topic

dae65

Dear Phil,

In the same spirit as the other thread about TrackNumber and DiskNumber in the QuickTime ItemList group, I'd like now to suggest that it might be a good idea to modify the corresponding ValueConv entries as well. Currently they are both defined as:

length($val) >= 6 ? join(" of ",unpack("x2nn",$val)) : \$val

As it is, this returns, say, "5 of 0" or "2 of 0" when the total number of tracks or disks is unknown. Here is an output from the exiftool application:

Track Number                    : 5 of 0
Disk Number                     : 2 of 0


I suggest ValueConv should conservatively read as follows:

my @a = unpack("x2nn",$val); pop @a if @a>1 && !$a[1]; length($val) >= 6 ? join(" of ", @a) : \$val

which simply shortens the array if the last element is zero, and so prevents join from needlessly appending an " of 0" to an integer. Here is a new output from the application:

Track Number                    : 5
Disk Number                     : 2


This will also make ValueConv the inverse of the updated ValueConvInv. Please find another diff file attached.

Thanks again.  :)

Phil Harvey

This will appear in ExifTool 12.02 when it is released.  (I had already done this when I allowed writing as in integer)

- 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 ($).