Need help with file naming

Hi everyone! New user here. I just started using MusicBrainz Picard a couple of days ago to sort my MASSIVE music collection of 70.000+ songs. I’ve tried adjusting the script a couple of times, with help from the Scripting page and scripts suggested in several topics. But I just can’t seem to get the hang of it. Could you please help me out?

This is the structure I want to have (and already pretty much do):
Alphabetical letter of first name/Artist/Year - Album/Disc number (if there’s more than one)/Track number (with a 0 if <10) - Title.

But there’s a couple of extra things I want that I can’t seem to get right.

  • I want the ‘Feat.’ moved from the artist tag to the title tag.
  • I want bands with ’ The’ (such as The Beatles) classified under the B folder, but still have the main folder set as ‘The Beatles’ and not ‘Beatles, The’. The end result would be Music/B/The Beatles/1965 - Help!/01 - Help!.mp3
  • I want albums with various artists named under the main album artist. The tags from various artists should still be included in the file, I just want the files all in the same folder. For example: The soundtrack to Catch Me If You Can is composed by John Williams. There are also songs on there by Frank Sinatra and Nat King Cole. What I want is them all under Music/J/John Williams/2002 - Catch Me If You Can (but with the original tags intact, this only for folder structure).

I know some things aren’t traditional, such as sorting artists by their first name but this is what I’m used to. I wouldn’t want to look under W for John Williams and see the folder ‘John Williams’ and I also don’t like seeing ‘Williams, John’.

Thanks in advance for helping out!

Install the Feat. Artists in Titles plugin

Other people are better at answering the scripting question but it should be possible.

3 Likes

Awesome, thanks! That works.

Since you say you already have most of the script working, I’ll only answer the questions in bullet points. I am definitely happy to help out beyond this, though, so feel free to ask if you have anything else you need or if I wasn’t particularly clear in anything below.

  1. @dns_server has the answer to moving feat. I don’t use the plugin myself, so I can’t give you any advice about using it myself if you ever run into trouble, but there’s others on here who can.

  2. That can be achieved by using $delprefix within $left – I’m not personally a fan of $firstalphacharacter because I’d want, say, “1984” to be under “1” and I’m not sure how it deals with other scripts. Sounds like you have that half there, but just be aware that $delprefix only has a limited list it trims by default (I’ve listed them explicitly because that default list doesn’t include “An”). If you have a lot of Spanish music, for example, you may want to add “El” and “La”.

    $left($delprefix(%albumartist%,prefixes=A,An,The),1)
    
  3. MusicBrainz doesn’t have any concept of “main album artist” so there’s no way to do that automatically. What you can do, though, is manually set a custom field that your naming script will use instead. I’ve actually added logic for two levels of that into my own script, one of which changes the name of the album artist folder, and the other which adds another level to the hierarchy so “Wasteland Wailers, The feat. Haymaker” and “Heed, Anneli and Wasteland Wailers, The” are both folders within “Wasteland Wailers, The” – I do use the sort names, but the logic is the same with the standard names. Sounds like you might only want the first, though, so let me know if you want the second as well, and I’ll tell you more about adding it. Either way, you’ll only have to do that for the files that aren’t sorted correctly by default, so you don’t have to worry about going through every album in your library.

    Anyway, in the bottom pane of Picard, you can right-click and select “Add new tag”. The dialog that opens has a dropdown list at the top that will let you select any of the standard names, but it is also allows you to type things in, and it’s perfectly happy to save fields that aren’t in that list – at least for most files; I think MP4s and one or two other filetypes don’t allow custom fields. Choose a name you’ll remember (and that you can type; Picard won’t remember that it exists so you’ll need to type it out every time you add it); I’ll use %artistfolder% for this post, but you can change that if you have something better.

    Then, in your script, put the following line at the top of your naming script, and then replace each time you use %albumartist% in your existing script with %_savealbumartist%. You can even add %artist% to the end of the list, as a fallback if your file doesn’t happen to have album information, but I don’t know enough about the rest of your script to want to put it in there myself.

    $set(_savealbumartist,$if2(%artistfolder%,%albumartist%))
    
1 Like

Thanks a lot for the detailed information, I’ll try that out and see how it works. This is my current script:

$if($and($eq(%compilation%,1), $eq(%albumartist%,Various Artists)), $unset(albumartist) $unset(albumartistsort))
$upper($firstalphachar($if2(%artist%),#))/%albumartist%/%date% - %album%/$if($gt(%totaldiscs%,1),Disc %discnumber%/,)/$num(%tracknumber%,2) - %title%

With this as the description:

music\T\The Beatles\1965 - Help!\07 - Ticket to Ride.mp3

When I put in your script in point 2, I get this:

$if($and($eq(%compilation%,1), $eq(%albumartist%,Various Artists)), $unset(albumartist) $unset(albumartistsort))
$left($delprefix(%albumartist%,prefixes=A,An,The),1) $upper($firstalphachar($if2(%artist%),#))/%albumartist%/%date% - %album%/$if($gt(%totaldiscs%,1),Disc %discnumber%/,)/$num(%tracknumber%,2) - %title%

music\B T\The Beatles\1965 - Help!\07 - Ticket to Ride.mp3

What did I do wrong? Do I need to put your script line somewhere else in the script?

That line of mine wasn’t a way of fixing what you already had, it was a replacement for it; you’ve put it before your existing $upper($firstalphachar(...)) call, so your script is now getting the “first letter” twice in two different ways. Remove the old function instead. :wink: And seeing that, I remembered that I forgot to add an $upper call to mine; you’ll probably want to put the $left(...) within the $upper(...) where you currently have $firstalphachar(...) so you don’t get lowercase folder names. Sorry!

1 Like

An alternative to the $left version would be to use $firstalphachar as you did, but using %albumartistsort% instead of %artist%:

$firstalphachar($delprefix(%albumartist%,prefixes=A,An,The),#)

The difference is in the handling of non alphabetic characters. The $left version will always use the very first character, while $firstalphachar uses only alphabetic characters and sorts everything else (e.g. numbers and punctuation marks) to a single special folder, by default # (but you can specify this in the call, just replace # in my example with whatever you want). So use the version you prefer :slight_smile:

And no need to use $upper with $firstalphachar, it does that by default.

2 Likes

Thanks for letting us know about the $upper/$firstalphachar interaction! It’s not on the scripting page and I don’t use the latter myself so I never had cause to check. As I said, I’d like having the numbers (theoretically) sorted individually, and more importantly I’d want Arabic or Chinese or whomever artists correctly sorted rather than lumped into a single folder. Of course, that would need me to first add that level to my hierarchy (which I might actually wind up doing after a few more artists) and probably turn off ASCII-only mode.

Since you seem to know the function, how would it handle É o Tchan, if Unicode isn’t being replaced? And for that matter, does the Unicode replacement happen at the beginning or the end of the naming script?