This concerns the tags in MP3 and M4A audio files.
When the Genre fields are read without a config file, the Genre is reported as words, eg. Classical, Blues, Rock etc.
If the Genre fields are used as part of a composite tag definition in a config file, an integer code number is returned for the composite tag, instead of the words.
The code returned for ID3v1 Genres in an MP3 file agree with the table shown here: http://www.exiftool.org/TagNames/ID3.html (http://www.exiftool.org/TagNames/ID3.html).
There is a similar table for Quicktime genres shown here: http://www.exiftool.org/TagNames/QuickTime.html#GenreID (http://www.exiftool.org/TagNames/QuickTime.html#GenreID), but there doesn't seem to be a similar correspondence for M4A files.
How can the command line and/or config file be changed so that the Genre fields are decoded into words, when used as part of a composite tag?
C:\WINDOWS\system32>exiftool -ver
10.49
C:\WINDOWS\system32>exiftool -config "" -genre W:\Test.MP3 W:\Test.M4A
======== W:/Test.MP3
Genre : Classical
======== W:/Test.M4A
Genre : Classical
2 image files read
C:\WINDOWS\system32>exiftool -config "W:\Test.Exiftool_config" -AnyAudioGenre W:\Test.MP3 W:\Test.M4A
======== W:/Test.MP3
Any Audio Genre : 32
======== W:/Test.M4A
Any Audio Genre : 33
2 image files read
"W:\Test.Exiftool_config" contains this code:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
AnyAudioGenre => {
Desire => {
0 => 'ID3v1:Genre',
1 => 'QuickTime:Genre',
},
ValueConv => q{
$val[2]=$val[0] if ($val[1] eq undef);
$val[2]=$val[1] if ($val[0] eq undef);
return "$val[2]";
},
},
},
);
Try this:
AnyAudioGenre => {
Desire => {
0 => 'ID3v1:Genre',
1 => 'QuickTime:Genre',
},
ValueConv => q{
return $prt[0] || $prt[1];
},
},
This also uses the "perl way" of selecting the QuickTime tag if the ID3v1 one is missing.
Thank-you for your quick and helpful response!
$prt worked as desired.
And thanks for the example of the || operator.