It’s actually not that hard, just don’t get intimidated by all the $, % and parantheses If you can write down a pattern like “ARTIST - (YEAR) ALBUM NAME” you can quite easily translate this to the proper script.
First have a look at what we need, see the available tags at https://picard-docs.musicbrainz.org/en/variables/tags_basic.html. We want the “ARTIST”, available tag for this could be albumartist
or artist
. This should be the name for an album folder, so albumartist
sounds what we need. To get the actual value for a tag enclose its name in percentage signs. So let’s start:
%albumartist%
Now we want the “YEAR”. There is no year tag, but date
. Let’s use this for now. If we want to add extra text like the “-” just write it down. We need to be careful with the parentheses, because those are special variables in scripting. We need to prefix them with a backslash. Let’s add this all:
%albumartist% - \(%date%\)
Now finally the “ALBUM NAME”, that’s simple, just use album
:
%albumartist% - \(%date%\) %album%
Looks nearly as what you had in your original question It’s not perfect yet: We get a full date instead of year. Also if you tag existing files they sometimes might not have the albumartist
set, just artist
.
Let’s fix the artist first. We can fallback to using artist
if albumartist
is not available by using
$if2(%albumartist%,%artist%) - \(%date%\) %album%
$if2
uses the first value that is not empty, so if albumartist
is empty it uses artist
instead.
For the date the dates from MusicBrainz are always formatted as YYYY-MM-DD
, e.g. 2020-11-02 for today. So let’s get just the first 4 characters with the $left
function:
$if2(%albumartist%,%artist%) - \($left(%date%,4)\) %album%
Let’s do one step more, which I did not have in my original answer. What happens if there is no date? Sometimes MusicBrainz does not have the release date of an album set as it is not known yet. Would be great to omit the entire date with the parentheses in this case. Let’s use the $if
function to check whether date
is set:
$if2(%albumartist%,%artist%) - $if(%date%,\($left(%date%,4)\) )%album%