A third common feature between the two groups above is that the aggregated genres in track 1 are the same. Working on the idea that that’s always correct, I’ve modified the scripts as follows.
Script A is unchanged.
In Script B, I set “aggregate_genre1” to be a new persistent variable from “_common_genre” from only track 1. Because the prior results have always shown the aggregate genre has the track 1 genre(s) added again at the end, I slice them off. The aggregate_genre is now correct with the proper length.
$noop( Script B - Set tags showing aggregated genres and aggrecate count )
$if($eq(%tracknumber%,1),
$set_a(aggregate_genre1,$get_a(_common_genre))
$setmulti(_temp,$replace($replace(%genre%,; ,;),;,; ))
$set_a(t1_genre_length,$lenmulti(%_temp%))
$unset(_temp)
)
$setmulti(aggregate_genre,$get_a(aggregate_genre1))
$setmulti(aggregate_genre,$slice(%aggregate_genre%,,-$get_a(t1_genre_length)))
$set(aggregate_genre_length,$lenmulti(%aggregate_genre%))
Script C is disabled.
…but the new Script D is the same except for using “aggregate genre” instead of “common_genre”.
$if(%_genre_count_processed%,,
$foreach($get(aggregate_genre),
$set(_genre_key,Genre '%_loop_value%' count)
$set(%_genre_key%,$add($if2($get(%_genre_key%),0),1))
$unset(_genre_key)
,; )
)
$set(_genre_count_processed,1)
Results:
The 25 genres are properly aggregated and the solo genre counts match:
Genre ‘Club’ count: “1”
Genre ‘Dance’ count: “1”
Genre ‘Electronic’ count: “9”
Genre ‘New Age’ count: “11”
Genre ‘Techno’ count: “3”
I get the same result with both file sets. I hope it’s robust.
I’m going to start a new script to derive an album genre list derived from the solo genre counts…