SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

SongKong - Filename mask questions

Hi Paul, it’s been some time! Just wondering as I tried a few approaches in the Filename mask, but I am not good with JavaScript and GPT is no help so far:

This has been my “base script” for some years:

ifnotempty2(albumartistsort.substring(0,1),"Z albumartistsort tag not found",'/')
+ ifnotempty2(albumartistsort,"Z albumartistsort tag not found",'/')
+ ifnotempty((year.length>4 ? year.substring(0,4):year),' ') 
+ ifnotempty(album,'/')
+ ifmultidisc(ifnotempty(pad(discno,2),'-'))
+ ifnotempty(pad(track,2),' ')
+ title
  1. Any general observations? What could be improved for “robustness”?

  2. How would change it so that ifmultidisc = yes, append it to album level in the structure like

    • ifnotempty(album,’ ')
    • ifmultidisc(ifnotempty(pad(discno,2),’/’))
      Problem here is that only very few releases have multiple discs and this destroys my folder structure.
      So in other words - how do I implement a conditional prepend separator rather than a conditional append separator ? Hope my question is clear.
  3. I want to generally change from albumartistsort to albumartist but for names starting with The, push that back like “Beatles, The” . Do you see any way of scripting that? I tried the following so far, but none is recognized and I am at my limited scripting wits end:
    a)

    ifnotempty( ifcontains(albumartist, "The ", removeleft(albumartist, 4) + ", The", albumartist), " - " ) + title

b)

ifnotempty(
   ifmatch(albumartist, "^The (.+)", word(1) + ", The"),
   "/"
) + title 

c)

if(artist=~"^The (.+)", fixcase("$1, The"), artist)

d)

if(startswith(albumartist,"The "),
   substringafter(albumartist,"The ") + ", The",
   albumartist
)

How about this

function nameWithoutThe(value){
   if(value.startsWith("The "))
   {
       return value.substring(4);
   }
   else
   {
       return value;
   }
}

ifnotempty(substring(nameWithoutThe(albumartist),1),'/')
+ ifnotempty(nameWithoutThe(albumartist),'/')
+ ifnotempty((year.length>4 ? year.substring(0,4):year),' ') 
+ ifnotempty(album,'/')
+ ifmultidisc('Disc ' + ifnotempty(pad(discno,2),'/'))
+ ifnotempty(pad(discno,2),' - ')
+ ifnotempty(pad(trackno,2),' - ')
+ title

e.g

Many thanks for the lightning fast response Paul, it’s definitely going in the right direction.
I am just lost how I would keep the “The” like in “Beatles, The” rather than make it disappear entirely. I am also still trying to add the Disc # to the same level as the album name my scripting is rudimentary. Many thanks for your help and a Merry Christmas for you and your family!

It would help me if you could take the three examples at the bottom of the screenshot and edit them to show what you would’ve to be like. I find actual examples easier to understand then trying to follow a description of the issue.

Had another go

function useSortNameIfNameStartsWithThe(value, sortValue){
    if(value.startsWith("The ") && sortValue.length>0)
    {
        return sortValue;
    }
    else
    {
        return value;
    }
}

ifnotempty(substring(useSortNameIfNameStartsWithThe(albumartist, albumartistsort),1),'/')
+ ifnotempty(useSortNameIfNameStartsWithThe(albumartist,albumartistsort),'/')
+ ifnotempty((year.length>4 ? year.substring(0,4):year),' ') 
+ ifnotempty(album,'/')
+ ifmultidisc('Disc ' + ifnotempty(unpad(discno),' '))
+ ifnotempty(pad(trackno,2),' - ')
+ title

e.g.

Thank you so much Paul, this definitely works for the “The”. In regards to conditionally adding the disc number if multidisk is present: I’d like to do that at the following level
{year} {album} {XXXXX}/track title

The problem with my attempt to amend your script is that I dont manage to make it work for all 3 examples:

function useSortNameIfNameStartsWithThe(value, sortValue){
if(value.startsWith("The ") && sortValue.length>0)
{
return sortValue;
}
else
{
return value;
}
}

ifnotempty(substring(useSortNameIfNameStartsWithThe(albumartist, albumartistsort),1),’/’)

  • ifnotempty(useSortNameIfNameStartsWithThe(albumartist,albumartistsort),’/’)
  • ifnotempty((year.length>4 ? year.substring(0,4):year),’ ')
  • ifnotempty(album,’ ')
  • ifmultidisc(ifnotempty(pad(discno),’/’))
  • ifnotempty(pad(trackno,2),’ ')
  • title

Basically Example 3 in the screenshot looks perfect but for the non multidisc Examples 1 & 2 the structure doesnt work as the folder separator doesnt fire.

Many thanks for your help so far!

Can I just point out to you that doing it how you want means you will end up with

  • Album Year Disc 1
  • Album Year Disc 2

This means you have no overall album folder , and this means many tools wil not realize that these discs are from the same album. The more usual approach would be:

  • Album Year
  • Album Year/Disc 1
  • Album Year/Disc 2

What do you think?

Right, I have licenzed and used Jaikoz and SongKong for many years, I use few other tools. I follow your logic, but which tools / websites are you referring to? Say would MusicBrainz, Discogs and other Services have a problem recognizing this structure? Any other services you can think of?

Yes, SongKong and Jaikoz themselvs would match these folders as seperate albums, they may end up matching all discs to the right disc on thew same album, but not guaranteed, Picard has the ssame issue as does Roon, in fact I thiink just about every single music tagger would have issues with this. Now once they are tagged correctly music players should work okay because they should work on the tags not the folder structure, but universally the expected folder structure for multi disc albums if to have each disc in a seperate folder under one common folder or (but less comon not as good) have all files from all discs in a single folder.

Many thanks Paul, have a Merry Christmas with your family! All the best for 2025

Merry Xmas

So I would recommend something like

  function useSortNameIfNameStartsWithThe(value, sortValue){
        if(value.startsWith("The ") && sortValue.length>0)
        {
            return sortValue;
        }
        else
        {
            return value;
        }
    }

    ifnotempty(substring(useSortNameIfNameStartsWithThe(albumartist, albumartistsort),1),'/')
    + ifnotempty(useSortNameIfNameStartsWithThe(albumartist,albumartistsort),'/')
    + ifnotempty((year.length>4 ? year.substring(0,4):year),' ') 
    + ifnotempty(album,'/')
    + ifmultidisc('Disc ' + ifnotempty(unpad(discno),'/'))
    + ifnotempty(pad(discno,2), ' ')
    + ifnotempty(pad(trackno,2),' - ')
    + title

e.g