Updated with a workaround to allow duplicate values:
$if($gt($lenmulti(%composersort%),1),
$set(_fixedComposersSort,)
$set(_atLeastOneComposerSortDiffers,0)
$foreach(%composersort%,
$set(_currentComposerSort,%_loop_value%)
$set(_currentIndex,$sub(%_loop_count%,1))
$set(_currentComposerName,$getmulti(%composer%,%_currentIndex%))
$noop(You can modify the sort name here if you wish. For example - swap prefixes etc.)
$if($ne(%_currentComposerSort%,%_currentComposerName%),$set(_atLeastOneComposerSortDiffers,1))
$noop(-- XXX: copymerge doesn't allow duplicate values.
$copymerge(_fixedComposersSort,_currentComposerSort)
)
$set(_fixedComposersSort,%_fixedComposersSort% %_currentComposerSort%)
)
$noop(Unset composers_sort if it's not necessary)
$if($eq(%_atLeastOneComposerSortDiffers%,0),$unset(_fixedComposersSort))
$noop(Map into MP3 / Vorbis / M4A - Picard apparently reads ALLCAPS m4a tags as lower case...)
$set(_composers_sort_field,composers_sort)
$noop(Picard is case sensitive, so MP3 TXXX and MP4 tags must be manually handled)
$if($eq_any($upper(%_extension%),MP3),$set(_composers_sort_field,$upper(%_composers_sort_field%)))
$noop(-- XXX: copymerge doesn't allow duplicate values, so don't join from a multi-value.
$setmulti(%_composers_sort_field%,$join(%_fixedComposersSort%, ), )
)
$setmulti(%_composers_sort_field%,%_fixedComposersSort%, )
$noop(Flatten M4A instruments tag: Mutagen writes multi-value tags that can't be read correctly by foobar2000, Mp3tag, etc.)
$if($eq($upper(%_extension%),M4A),
$set(%_composers_sort_field%,$join($get(%_composers_sort_field%),; ))
)
$unset(composersort)
)
$if($gt($lenmulti(%composer%),1),
$noop(Map into MP3 / Vorbis / M4A - Picard apparently reads ALLCAPS m4a tags as lower case...)
$set(_composers_field,composers)
$noop(Picard is case sensitive, so MP3 TXXX and MP4 tags must be manually handled)
$if($eq_any($upper(%_extension%),MP3),$set(_composers_field,$upper(%_composers_field%)))
$setmulti(%_composers_field%,$join(%composer%, ), )
$noop(Flatten M4A instruments tag: Mutagen writes multi-value tags that can't be read correctly by foobar2000, Mp3tag, etc.)
$if($eq($upper(%_extension%),M4A),
$set(%_composers_field%,$join(%composer%,; ))
)
$unset(composer)
)