Best file name code for my archive?

Hi,

I’m new and I using this code for my files:


$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
[Various Artists],
$left($if2(%albumartistsort%,%artistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, (Disc %discnumber%),),)
/
$num(%tracknumber%,2). $left(%title%,120),[:?"_]+,), , )


But it gives me the name of file like this:

H:\Music\R\Ritter, Josh[2006] The Animal Years\08. Good Man.mp3

and I like to be like this: (name and then surname of Artis without comma)

H:\Music\J\Josh Ritter[2006] The Animal Years\08. Good Man.mp3

also, I don’t like [Various Artists] folder. How should I deal with that type of music? any idea?

Everything you’re asking about is contained in this part of the script, so lets pull it apart.

$if($eq(%albumartist%,Various Artists),

This part checks if the AlbumArtist tag is “Various Artists”. If it is, then:

[Various Artists],

The next bit of text in the file path is “[Various Artists]”. If the tag isn’t “Various Artists” then:

$left($if2(%albumartistsort%,%artistsort%),1)/

The next bit of text is the first letter in the tag AlbumArtistSort and a slash to mark the beginning of the next directory. This tag variable %albumartistsort% is where you get the sort version of the name. Since you want to use the non-sorted name, you need to replace %albumartistsort% and %artistsort% with %albumartist% and %artist%.
Next:

$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))

The sets the next bit of the file path to the sort name of the album artist. Again, you’ll want to replace these with non-sort versions. The $left statement is there to limit the artist name to 60 characters or less, and the $rreplace is removing some symbols from the name.

There’s documentation for scripting and file naming here:
https://picard.musicbrainz.org/docs/scripting/
And you can find more info about the tag variables here:
https://picard.musicbrainz.org/docs/tags/

As for the question of what to do with Various Artists, that’s up to you. If you remove the if statement, this script will create an artist folder under the “V” folder called Various Artists and add album folders in there just like any other artist. One thing I had considered in my own script (but eventually decided against) was to file VA compilations among the artists, but by the album name. So an album called “British Invasion Classics” would be in the “B” folder along with The Beatles and Boomtown Rats.

Something to consider about using AlbumArtist instead of AlbumArtistSort is all band names starting with “The” will be sorted into the “T” folder. You might want to look into the use of the $swapprefix function to move the “The” to the end of the artist name without affecting the people names.

9 Likes

Thank you so much for your reply.

1 Like

@Billy_Yank Nice reply, great content for understanding scripting. Easily understood!! :smile: