Ensuring Sort Tags

This is a series of posts I’m putting up to support people using MusicBrainz Picard with Serento. It’s scripting functionality is a little daunting to start with but is incredibly powerful. You can create scripts which run either when you drop in an album to tag or to run manually. I will update these posts as my own scripts evolve.

Feel free to use these as a basis and make your own, or post any questions and I’ll be happy to help where and when I can!

You can create and edit scripts under OPTIONS > Scripting

If you tick the box next to the script the script will run automatically.

If you do not tick the box you select the files you want to run the script on, right click and go to RUN SCRIPTS > (name)

These scripts are intended to add missing sort fields where not present. There are 2 different scripts.

Ensure Sorts (for People)

I run this when the main Artist / Album Artist is a person:

# Create the sort fields
$if(%artist%,$if(%artistsort%,,
    $set(artistsort,$swapprefix(%artist%,$substr(%artist%,0,$find(%artist%, ))))
))

$set(__temp_aa,$lower(%albumartist%))
$if($or($eq(various artists,%__temp_aa%),$eq(various,%__temp_aa%)),
    $set(albumartist,Various Artists)
    $set(albumartistsort,Various Artists),
    $set(%albumartist%,Various Artists)
    $if(%albumartist%,$if(%albumartistsort%,,
        $set(albumartistsort,$swapprefix(%albumartist%,$substr(%albumartist%,0,$find(%albumartist%, ))))))
)

$if(%artist%,$if(%artists%,,
    $setmulti(artists,%artist%)))

$if(%band%,$if(%band_sort%,,
    $set(band_sort,$swapprefix(%band%))))

$if(%choir%,$if(%choir_sort%,,
    $set(choir_sort,$swapprefix(%choir%))))

$if(%composer%,$if(%composersort%,,
    $set(composersort,$swapprefix(%composer%,$substr(%composer%,0,$find(%composer%, ))))))

$if(%ensemble%,$if(%ensemble_sort%,,
    $set(ensemble_sort,$swapprefix(%ensemble%))))

$if(%orchestra%,$if(%orchestra_sort%,,
    $set(orchestra_sort,$swapprefix(%orchestra%))))

$set(__temp_aa,)

Ensure Sorts (for Bands)

I run this when the main Artist / Album Artist is a band:

# Create the sort fields as copies - No sort changes
$if(%artist%,$if(%artistsort%,,
    $set(artistsort,$swapprefix(%artist%))))

$if(%albumartist%,$if(%albumartistsort%,,
    $set(albumartistsort,$swapprefix(%albumartist%))))

$if(%artist%,$if(%artists%,,
    $setmulti(artists,%artist%)))

$if(%band%,$if(%band_sort%,,
    $set(band_sort,$swapprefix(%band%))))

$if(%choir%,$if(%choir_sort%,,
    $set(choir_sort,$swapprefix(%choir%))))

$if(%composer%,$if(%composersort%,,
    $setmulti(composersort,$swapprefix(%composer%))))

$if(%ensemble%,$if(%ensemble_sort%,,
    $set(ensemble_sort,$swapprefix(%ensemble%))))

$if(%orchestra%,$if(%orchestra_sort%,,
    $set(orchestra_sort,$swapprefix(%orchestra%))))