SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

Please Help with Folder/Filename Script

When I tested out the program, I did not realize the complexity of writing folder/filename masks. :shock: I do not know Javascript and I am not a programmer. I’m just a guy that has an already established folder/filename convention. Would some please help me create a script to accomplish the following. It would be much appreciated. :slight_smile:

Here’s a link to a Google Doc of the code pasted below: https://docs.google.com/document/d/1mSxHUhbtTujxhr6vHbB1-9omEwprHxhk5JxCuIJ1-Dc/edit?usp=sharing

Single Album Artist - Single Disc Album

[Album Artist] or [Album Artist Sort]?/
[Original Release Year]([MONTH(number form)] - [Album Title] or [Album Title Sort]?/
[Release Year][Country][Media][Code (last four digits of Musicbrainz ID or Discogs ID or random numbers if neither are available)]/
[Track Number] - [Song Title]

Reed, Lou/1997(02) - Set the Twilight Reeling/1996USCD67a31/ 01 - Egg Cream

Who, The/1967(12) - Who Sell Out, The/2012JPSHMSACDe5c6/01 - Armenia City in the Sky (mono)

Jefferson Airplane/1968(09) - Crown of Creation/1989USVINYLe1208/01 - Lather

Single Album Artist - Multiple Disc Album

[Album Artist] or [Album Artist Sort]?/
[Original Release Year]([MONTH(number form)] - [Album Title] or [Album Title Sort]?/
[Release Year][Country][Media][Code (last four digits of Musicbrainz ID or Discogs ID or random numbers if neither are available)]/
[Disc Number (formatted D01 (two digit)]\\
[Track Number] - [Song Title]

Davis, Miles/1970(03) - Bitches Brew/1999XECD5cc2/D01/01 -Pharoah?s Dance

Davis, Miles/1970(03) - Bitches Brew/1999XECD5cc2/D02/01 -Spanish Key


Misfits, The/1996(02) - Box Set/1996USCD377ca/D01/01 - She

Misfits, The/1996(02) - Box Set/1996USCD377ca/D02/01 - Static Age

Misfits, The/1996(02) - Box Set/1996USCD377ca/D03/01 - Cough/Cool (1977 session A) 

Misfits, The/1996(02) - Box Set/1996USCD377ca/D04/01 - Static Age Intro

Various Artist (Compilation) - Single Disc Album

[Various Artist]/
[Album Title] or [Album Title Sort]?/
[Release Year][Country][Media][Code (last four digits of Musicbrainz ID or Discogs ID or random numbers if neither are available)]/
[Track Number] - [Song Artist] - [Song Title]

Various Artists/No New York/1978USVINYLf225/01 - James Chance and the Contortions - Dish It Out

Various Artists/Roots of Rhythm: Deep Blues/2001USCD030c/01 - Arthur ?Big Boy? Crudup - That?s All Right

Various Artist(Compilation) - Multiple Disc Album

[Various Artist]/
[Album Title] or [Album Title Sort]?/
[Release Year][Country][Media][Code (last four digits of Musicbrainz ID or Discogs ID or random numbers if neither are available)]/
[Disc Number (formatted D01 (two digit)]\\
[Track Number] - [Song Artist] - [Song Title]

Various Artists/Crescent City Bounce, From Blues to R&B in New Orleans/2007UKCDdff1/D01/01 - Archibald - Stack-A-Lee Pt. 1

Various Artists/Crescent City Bounce, From Blues to R&B in New Orleans/2007UKCDdff1/D02/01 - Tom Ridgely - Boogie Woogie Mama

Various Artists/Crescent City Bounce, From Blues to R&B in New Orleans/2007UKCDdff1/D03/01 - Earl Johnson - Have You Gone Crazy

Various Artists/Crescent City Bounce, From Blues to R&B in New Orleans/2007UKCDdff1/D04/01 - The Royal Kings - Bouncin? the Boogie





We need to provide predefined masks like we do with SongKong but that is quite a file-naming mask you have their, please be patient and Ill try and post a solution later today.

One question you say [quote][Album Artist] or [Album Artist Sort]?[/quote]

By this you mean use AlbumArtist unless not available then use AlbumArtistSort, Jaikoz would never add an AlbumArtistSort without AlbumArtist unless you expressly configured it to so do we need this logic or can we just use AlbumArtist.

Thanks for the quick reply.

I wasn’t sure which was the best tag to use to get the “Last Name, First Name” and “Bandname, Article (A, An, The, Der)” format.

About 12 years ago, I tried to come up with a semantic folder/filename system that made sense to me. Over time it has evolved with the creation of MusicBrainz.

In most of my programs, I have tried to get the basic folder/filename structure, then I go in and do the manual renaming and additions to the folder names. So I’ve been manually doing Last Name, First Name and moving the articles to end of the Bandname and adding the last 4 digits of the MusicBrainz album ID.

I am extremely grateful for your assistance. It matches the level of commitment to the quality of the software that helped me choose Jaikoz.

Hi, sorry for the delay here is the mask for Rename mask. As you can see pretty much anything is possible. However it does remind me I need to improve Jaikoz to have a wide range of preset masks and functions as it is no-trivial to create comple masks.

First we create some Javascript functions, then we use those functions to help create our mask.

Single Artist Rename Folder from Metadata mask (both singledisc and multidisc)

function pad(number, length) {
   if (number == '') { return '';}
   var str = '' + number; 
   while (str.length < length) {  
      str = '0' + str;
   }
   return str;
}

function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }
 
 function ifnotempty2(value1,value2,sep){
     return value1.length > 0 ? value1 + sep :value2.length > 0 ? value2 + sep:'' ;
 }

function substring(value,length){
     return value.length > length ? value.substring(0,length)  : value;
 }
 

function substring2(value,start, end){
     return value.length >  end ? value.substring(start,end)  : '';
 }

function bracketif(value){
     return value.length > 0 ? '(' + value +')' : '';
 }

function getFourDigitId()
{
   if(mbreleaseid.length>0) return substring2(mbreleaseid,31,35);
   if(mbtrackid.length>0) return substring2(mbtrackid,31,35);
   if(acoustid.length>0) return substring2(acoustid,31,35);
}

function ifmultidisc(value) {
   if(disctotal>1)
   {
      return value;
   }
   else
   {
      return "";
   }
}

 ifnotempty2(albumartistsort,albumartist,folderseparator) + 
 ifnotempty(substring(originalyear,4) + bracketif(substring2(originalyear,5,7)), ' - ') + 
 ifnotempty(album,folderseparator) +
 substring(year,4) +
 media +
 getFourDigitId() + 
 folderseparator +
 ifmultidisc('D' + pad(discno,2))

Single Artist Rename Filename from Metadata mask (both singledisc and multidisc)

function pad(number, length) {
      if (number == '') { return '';} 
      var str = '' + number; 
      while (str.length < length) {  
          str = '0' + str;
      }
      return str;
  }
 
 function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }

 
ifnotempty(pad(trackno,2),' - ') + title

Compilation rename mask

Note currently a compilation (as defined by Is Compilation flag) is not necessarily a ‘Various Artists’ compilation, it can also be a single artist compilation so in the mask we use an album artist rather than ‘Various Artists’, but it would render as a ‘Various Artists’ for an actual Various Artists compilation.

Compilations was done this way for compatability with MusicBrainz and MusicBrainz Picard. But Picard has moved to the iTunes style definition and we do plan to move Jaikoz over as well, but additionally add a SA Compilation (Single Artist Compilation) field as well for those releases that would previously be marked as a compilation by Jaikoz but are no longer.

Folder:Compilation rename mask

function pad(number, length) {
   if (number == '') { return '';}
   var str = '' + number; 
   while (str.length < length) {  
      str = '0' + str;
   }
   return str;
}

function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }
 
 function ifnotempty2(value1,value2,sep){
     return value1.length > 0 ? value1 + sep :value2.length > 0 ? value2 + sep:'' ;
 }

function substring(value,length){
     return value.length > length ? value.substring(0,length)  : value;
 }
 

function substring2(value,start, end){
     return value.length >  end ? value.substring(start,end)  : '';
 }

function bracketif(value){
     return value.length > 0 ? '(' + value +')' : '';
 }

function getFourDigitId()
{
   if(mbreleaseid.length>100) return substring2(mbreleaseid,31,35);
   if(mbtrackid.length>0) return substring2(mbtrackid,31,35);
   if(acoustid.length>0) return substring2(acoustid,31,35);
}

function ifmultidisc(value) {
   if(disctotal>1)
   {
      return value;
   }
   else
   {
      return "";
   }
}
 
ifnotempty(albumartist,folderseparator) +
 ifnotempty(album,folderseparator) +
 substring(year,4) +
 media +
 getFourDigitId() + 
 folderseparator +
 ifmultidisc('D' + pad(discno,2)) 

and Compilation File mask

function pad(number, length) {
      if (number == '') { return '';} 
      var str = '' + number;
      while (str.length < length) {
          str = '0' + str;
      }
      return str;
  }
                                              
 
 function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }
 
 function ifnotempty2(value1,value2,sep){
     return value1.length > 0 ? value1 + sep :value2.length > 0 ? value2 + sep:'' ;
 }
 
  
ifnotempty(pad(trackno,2),' - ') + ifnotempty(artist, ' - ') + title

Wow, much gratitude for all the work you put into this. I tested it out, and it works quite well.

In 8th grade (14 years old) math, I was taught algorithms. I wish that knowledge easily translated to computer languages.

Again, thanks for your work.

:smiley: