I gave this a go with a slightly different approach:
https://raw.githubusercontent.com/phw/picard-plugins/releasetag_aggregations/plugins/releasetag_aggregations/releasetag_aggregations.py
Note: The functions names starting with $album_
were previously called $releasetag_
. I changed this with an update to version 0.4 and have updated this post accordingly.
This plugin provides a couple of functions that can be used to get aggregated values from all files on the release. Note: Due to technical limitations these functions work only when used in a naming script.
E.g. one can use the following to get a common media (note: variable names must be passed by name, e.g. media
, not with value, e.g. %media%
):
$album_all(media)
If all files have the same value for media
(e.g. “CD”) that value will be returned, otherwise it will be empty. You can use this to just check whether all files have the same type or not:
$if($album_all(media),all same media type,different media type)
For handling numeric values e.g. for including the bitrate in a folder name there are $album_min()
, $album_max()
and $album_avg()
. E.g. you could do a bitrate range:
$album_min(_bitrate)-$album_max(_bitrate)
Or to have it use only a single value if all files are identical combine it with $album_all
:
$if2($album_all(_bitrate),$album_min(_bitrate)-$album_max(_bitrate))
Another option is to use an average bitrate:
$album_avg(_bitrate)
For something like genres you might want to use the most common value. There is $album_mode()
for this:
$album_mode(genre)
If you have 4 files tagged with a genre of “rock” and 3 with genre “metal” this will use “rock”. Now often there are multiple genres in a file (that means a genre tag is a multi-value tag). Let’s assume we have a release with individual tags tagged with the following genres:
- rock; metal
- rock; blues
- blues
- rock; metal
- blues; alternative
- blues; jazz
Using $album_mode(genre)
would pick “rock; metal” as the genre, because this is the most common combination. But maybe you want the most common single value? There is $album_multi_mode()
for this:
$album_multi_mode(genre)
This looks at all the values individually and hence will give “blues” (which is used 4 times, followed by rock 3 times).
There are also multi tag variations of min, max and average ($album_multi_min()
, $album_multi_max()
, $album_multi_avg()
).
To install the script the easiest is to download the file releasetag_aggregations.py from https://raw.githubusercontent.com/phw/picard-plugins/releasetag_aggregations/plugins/releasetag_aggregations/releasetag_aggregations.py and install it from inside Picard via Options > Plugins > Install plugin…