ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: dae65 on July 24, 2020, 11:02:02 AM

Title: patch to read track and disk numbers as integers when total number is unknown
Post by: dae65 on July 24, 2020, 11:02:02 AM
Dear Phil,

In the same spirit as the other thread (https://exiftool.org/forum/index.php?topic=11458.0) 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.  :)
Title: Re: patch to read track and disk numbers as integers when total number is unknown
Post by: Phil Harvey on July 25, 2020, 06:43:53 AM
This will appear in ExifTool 12.02 when it is released.  (I had already done this when I allowed writing as in integer)

- Phil
Title: Re: patch to read track and disk numbers as integers when total number is unknown
Post by: dae65 on July 25, 2020, 07:59:28 AM
Great! Thanks.