SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

Help With Rename Masks?

I’ve been looking around and can’t find anywhere that gives a full list of rename functionality, so I’m left a bit lost as to syntax.

Here’s what I want to do -

FileName - Seperator (~)

  1. Artist
  2. (If there is a match to MBtrackID I want to put in a !, if no match, a space)
  3. Album
  4. Track #
  5. Track

So basically, if there as a MB match, the file would look like this:
Artist ~ ! ~ Album ~ Track# ~ Track
And if no match:
Artist ~ ~ Album ~ Track # ~ Track

Also, how the heck do I get rid of the underscores in the rename?

Thanks for any help.

I think this is the mask you want

(albumartist.length>0  ? albumartist 
+' ~ ' :(artist.length>0 ? artist + ' ~ ' : ' ')) 
+ (mbtrackid.length>0 ?  ' !  ~ ' :' ~ ')
+ (album.length>0 ? album + ' ~ ' :'') 
+ (trackno.length>0 ? trackno + ' ~ ' :'')  
+ title

If there are specific chars you always want removed/changed you can add them in Preferences:File and Folder Correct:File and Folder Naming:Replace 'From Character with ‘To’ Character

Is there a writeup somewhere of how the, now new, rename mask scheme works?

I have a “highly customized” one I use in MusicBrainz’ Picard app and I’ve been using that to move/rename my files because of that, but if I can get Jaikoz to perform the same way it would make my life that much easier.

thanks!

There is no writeup but its just Javascript so any Javascript reference should be able to help, but if you post the Picard mapping and progress might be able to help.

I’m not really sure what I’m looking for as far as “javascript reference” for this.

would you mind sharing a link or two that I can read over?

thanks!

What is the correct syntax to change the file name to simply the ISRC code?

It used to work fine with %isrc% but now it generates a syntax error?

clicking isrc in the list generates +" "+ isrc but this adds a preceding 0 to the file name (ie 0XXXXXXXX) where X’s are the actual ISRC info. I just want the filename to be X.mp3 where X equals the ISRC No leading zero or space or anyting.

Thanks!

The syntax has completely changed to Javascript now, which gives way more flexibility (at the cost of a higher initial learning curve).

Just adding isrc should just display the isrc as is, if the isrc field itself contains a leading zero that you dont want you can do this

(isrc.length>0? isrc.substring(0,1)

Just Google for JavaScript tutorial and you will get more info than you want.

Not that I am a JavaScript writer but I think what might be confusing to people is the single line IF statement format, which took me some time to find a tutorial about this format.

See http://javascript.about.com/od/decisionmaking/a/des10.htm for more info.

But what is happening is that the normal IF/THEN/ELSE syntax like the following

IF (condition)
THEN
true-value
ELSE
false-value

is getting converted to a one line statement like

(condition) ? true-value : false-value;

Example:

If you had this IF/THEN/ELSE statement

IF ((albumartist.length>0 )
THEN
albumartist=albumartist + ’ ~ ’
ELSE
IF (artist.length>0)
THEN
artist = artist + ’ ~ ’
ELSE
artist= ’ ’

could be converted to a one line statement like

(albumartist.length>0 ? albumartist
+’ ~ ’ :(artist.length>0 ? artist + ’ ~ ’ : ’ '))

where

( ) / encloses the IF statement (IF)

? / start of the true condition (THEN)

: / start of the false condition (ELSE)

.length / is a built in function that returns the length of the variable that it is attached to. So artist.length returns the number of characters in artist. >0 is checking to see if that number is greater than zero. see (http://www.tizag.com/javascriptT/javascript-string-length.php) for more information on this function and others

  • / is a concatenation symbol. So if artist = “robert” then
    artist + ’ ~ ’ would be “robert ~”

It might help if you write what you want to do in the IF/THEN/ELSE format then go back and put it in the one line format.

Hope you are not more confused. The two URLs will give you more information.

Robert ~

Robert: Thanks for that excellent explanation!

For Jaikoz, is there a way to do regexp or similar replacements? So, for instance, renaming bands whose names start with “The …” to move the “The” part to the end, “…, The”?

Yes, anything you can do with Java script expressions you can do with Jaikoz, that is the point.

For example
To force to use 2 digit track numbers, rather than 3 digits?

(trackno.length>0 ? trackno.replace(/[0-9]([0-9]{2})/g,'$1'):trackno)

But I think in your particular example you should just use the Sort Artist field because this field would already store ‘The Beatles’ as ‘Beatles, The’

ok, so to see if a field has information we use

trackno.length>0
or
album.length>0
etc?

also, is there a way to include relationship information (like “featuring” artists, or “cover of” artists)?

how do I insert the disc sub title?

also, I’m trying this, but it’s saying it’s invalid:

(albumartistsort.length>0  ? albumartistsort +folderseparator :
(artistsort.length>0 ? artistsort + folderseparator :
(albumartist.length>0 ? albumartist + folderseparator :
(artist.length>0 ? artist + folderseparator : ''))))
 + (year.length>0 ? '[' + year + '] ' : '') + album ( disctotal>1 ? folderseparator + 'disc ' discno + folderseparator :'')

I assume it’s from disctotal>1, but how do I get it to see if the value of disctotal is a number greater than 1?

Your code is rather complicated so what I would suggest break it down to simple parts and try some test. The “Example Mask” is your friend and can save you time with simple tests.

So try the following

( disctotal>0 ? folderseparator : ’ ') Example Mask shows “/”

We will assume that disctotal is greater than 0. See if you get a folderseparator in the Example Mask.

NOTE: To get the changes to take affect click in the compilation mask box if you are working in the rename mask box.

Just keep adding to the javascript until it stops working.

( disctotal>0 ? folderseparator + 'disc ’ : ‘’) Example mask shows “/disc”

( disctotal>0 ? folderseparator + 'disc ’ discno : ‘’) Example mask shows nothing. So added discno caused the problem

the “+” is missing between 'disc ’ and discno.

( disctotal>0 ? folderseparator + 'disc ’ + discno : ‘’) Example mask shows “/disc 1”

Hope this helps.

Hi everybody.

I really have an hard time trying to learn Javascript on the go :slight_smile: and i would like some help to build a script that will make the following work

Is it possible to build a script with all the four conditions ?
If someone of you is kind enough to build it for me i would easyly send 20usd by Paypal, to thank you for helping me so far in the coding.

Here below the old way of renaming filename
Cheers Martin (agaragar)


if the album is only one CD:
%albumartist% - %album% - %trackno% - %title%

example:
MARTHA AND THE MUFFINS - METRO MUSIC - 07 - MONOTONE

if the album is only one CD but have differents artists in the artist tag:
%albumartist% - %album% - %trackno% - %artist% - %title%

example:
VARIOUS ARTISTS - COFFEE TABLE MUSIC - 01 - SUSAN BROWN - HOW WE USE TO LIVE

for the 2 following way to arrange filenames
i used to use discno and tracno togheter and it’s perfect but with the javascript
instead of having “101” for the first song of the first CD
i have only “11” because it doesnt pad the numbers below 10 with a zero.
Can it be fixed in a the script ?


if the album is two or more CD:
%albumartist% - %album% - %discno%%trackno% - %title%

example:
CONVERTER - EXPANSION PACK 2.0 - 203 - INVOCATION OF LILITH

if the album is two or more CD but have differents artists in the artist tag:
%albumartist% - %album% - %discnotrackno% - %artist% - %title%

example:
VARIOUS ARTISTS - THE MIX 50 - 317 - ADAMSKI - KILLER(ORIGINAL VERSION)

[quote=rpm4fsu]Your code is rather complicated so what I would suggest break it down to simple parts and try some test. The “Example Mask” is your friend and can save you time with simple tests.

So try the following

( disctotal>0 ? folderseparator : ’ ') Example Mask shows “/”

We will assume that disctotal is greater than 0. See if you get a folderseparator in the Example Mask.

NOTE: To get the changes to take affect click in the compilation mask box if you are working in the rename mask box.

Just keep adding to the javascript until it stops working.

( disctotal>0 ? folderseparator + 'disc ’ : ‘’) Example mask shows “/disc”

( disctotal>0 ? folderseparator + 'disc ’ discno : ‘’) Example mask shows nothing. So added discno caused the problem

the “+” is missing between 'disc ’ and discno.

( disctotal>0 ? folderseparator + 'disc ’ + discno : ‘’) Example mask shows “/disc 1”

Hope this helps.
[/quote]

a little, why disctotal>0? I don’t want a disc folder if there is only one disc.

my problem with the “example” thing is it completely won’t work if one of the “if” statements is “broken”.

thanks!

doesn’t seem to work. I’d like to have it so it places the year without the month/day if it exists in the metadata.

thanks!

[quote=TinCanFury]
a little, why disctotal>0? I don’t want a disc folder if there is only one disc.

my problem with the “example” thing is it completely won’t work if one of the “if” statements is “broken”.

thanks![/quote]

Are you familiar with the “Example Mask” and “Example Compilation Mask” in the Preference/File and Folder Correct/Rename Folder from Metadata?

Jaikox has some built-in data that you can test your script with.

I have attached a screen shot of my script and the Example Mask output. I do not have any data with Boy/U2. This is built in to make testing your script easier.

A snippet of you code above you had

 ( disctotal>1 ? folderseparator + 'disc ' discno + folderseparator :'')

I was not sure if the sample data had a disctotal value greater than one, so I used disctotal>0 assuming that the sample data had a value of 1.

I just wanted to do get the “if” statement working. This is how I found the missing “+” sign.

Once I got it working with disctotal>0 the I know the syntax is OK and I can then change it to disctotal>1 knowing that it works.

IGNORE

[quote=TinCanFury]```(year.length>0 ? ‘[’ + year + '] ’ : ‘’)



doesn't seem to work. I'd like to have it so it places the year without the month/day if it exists in the metadata.

thanks![/quote]

year.length>0 is checking to see if there are one or more characters in the year field. Are you sure there is a year value?

To test the syntax of the if statement try

(year.length>0 ? ‘[’ + ‘TRUE’ + ‘]’ : ‘FALSE’)



If this works then you know the syntax is OK. Now you can replace 'TRUE'  with year and 'FALSE' with ''.

If you want to test the TRUE and FALSE sides of the if statement you can just change > to <.

Your second request is not so easy. There are so many formats of the year data it would not be an easy task to just pull out the year.

yes, I’ve been using it, the problem is when you start doing nested IF statements it’s not as useful to figure out where it’s “broken” and not working.

gotcha! makes sense, wasn’t sure if the >0 was for another reason.

thanks!

no, that’s part of the problem, I don’t know, but if it does exist I’d like to use it.

from what I’ve seen, and I believe it’s how the musicbrainz data is stored, the year format is always just the 4 digit year or the 4 digit year followed by the month/day. in Picard I use this:
$if(%date%,[$left(%date%,4)] )
which basically says if there is date information, thake the left hand 4 digits only. I’d like this, but, of course, in javascript.

thanks!