SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

getting the js rename working

I am trying to get the file and folder rename working but running into issues. I can’t even seem to get the Example Mask to show up. Something as simple as changing:

(albumartist.length>0  ? albumartist +'/' :'') + album

to

(albumartist.length>0  ? albumartist +'\\' :'') + album

causes the example remask to not show up. Notice all I changed was the folder separator to be windows friendly.

What I am ultimately trying to do is the following:

Best Artist folder then a sub folder with album date if it has one in parenthesis, space, then the album name, then the release country in parenthesis proceeding with a space, if it has one, then if it has more than 1 disc in the set, a space and the word ‘disc’ disc number ‘of’ total discs, in parenthesis.

Something like: Queen\(2011) Example Album (US) (disc 1 of 3)\

think i got the folder seperator to at least show up correctly in the example mask. Had to escape it with a double \\. Wish there was a tutorial or a better UI for the new renaming options. Super powerful, but almost have to need a very basic understanding of js syntax to get it to work.

Ok, got all but the disc number to work now. Here is the code:

How do i do the disc number? Not seeing any disc total mask. I am trying to get it so that disc one will only show the additional info that it is disc one in the file name if it is part of a set.

Adding this should work

+ (disctotal > 1 ? discno : '')

I accept what you say about the difficulty of the Javascript syntax, if you can suggest another scripting language that is more user friendly it may be possible to add it. But the javascript syntax does allow you to do pretty much what you want.

Cool. I will give that a try. Didn’t see disctotal as one of the available options in the bottom box, so wasn’t sure it would work.

Syntax wise, yeah, javascript would probably be the easiest.

[quote=paultaylor]Adding this should work

+ (disctotal > 1 ? discno : '')

I accept what you say about the difficulty of the Javascript syntax, if you can suggest another scripting language that is more user friendly it may be possible to add it. But the javascript syntax does allow you to do pretty much what you want.

[/quote]
Why not just use the POSIX regular expressions that we all already know and love.

Regex is super powerful, but dang its ugly. Those that are not familiar with any type of programming will have hard enough time with javascript, let alone trying to figure out regex.

Perhaps you are right greengeek but once you go regex you never go back :wink:

Two points to make:

1.Most people who would consider using this software are not computer novices and furthermore of that set those that would use an advanced renaming feature would not be put off by regex but would appreciate the power and flexibility.

  1. There is a wealth of regex documentation on the internet including numerous examples that would probably render any issue, such as the one you were having, instantly solved with a single Google search

Bonus point: I find most software that lets you use regex usually tests the expression first (for validity) and also allows you to see what the result would look like before any changes were made. This would help those new to regex. You could also share expressions in this forum and perhaps even save them as ‘canned’ operations within Jaikoz

I dont really see how regexp would work because it is just pattern matching, it doesnt have a concept of fields and it hasnt got anything to match to.

i.e keeping it really simple what would be the regexp for just displaying the artist field, there ius no starting String only a desired ending String.

BTW The javascript expressions are now validated and applied against an example song in the Preferences dialog.

I wrote a great (and long) reply to this and accidentally closed my browser so you’ll have to settle for me saying Yes it would work so long as you had data - and if you don’t then what is the point of using anything? Fields do exist as a concept in regexp you just delineate them yourself based on the source. Also see AWK. I can’t match your pattern unless I have a source for the artist but I thought the subject was file and folder renaming so it is reasonable to assume that you would have that information.

AWK is a possibility, and I used it alot myself about 20 years ago, but I think for most users its too hard. Not all my users are computer guys at all, although you guys tend to be the one posting on the forum.

But I really dont get what form a pure regular expression could take.

i.e you could say ([a-z].*) to match some word from some source but you cant write (artist) to match the artist field

Im sure you do have an answer, but until you have time to show me that answer I think Im going to be in the dark.

Even in your example (artist) is coming from somewhere, right? You have coded the program to be able to extract the artist information and make it available by using the expression (artist). It must come from somewhere. If you don’t have something to act upon then no expression, JS, awk, regexp, or anything would be useful. Otherwise it would require telepathy. (hmm Feature Request?)

You would need a source but you must already have one or else none of this could be done.

It depends on the particular use-case but for a given function you will usually have input -> (transformation) -> output. It would be no different here we are only talking about using regexp for the transformation function. It sounds like you are saying you don’t have any input but that simply can’t be.

Yes, it would depend on what the source looks like. On one side you would show the source, on the other the result of the expression. So, no, there would not be a preset variable for artist, unless you count back references. I think I just get what you are saying. You are trying to make it so that one variable will always equal a metadata field and I’m saying that you would just look at what was in that field and operate on it. Displaying the metadata isn’t part of the regexp but part of the interface.

You would act on the displayed output of the current value for artist. It would be much easier to discuss this or determine if it were feasible if the exact use-cases were well defined.

Yes of course I have a source, but I cant think how you want that presented to apply a regular expression on it.

Here a simple case I want my filename mask to be

artist-album-title

What would you like to add as the regexp to generate that output (the values of artist, album and title fields for each song are available)

I guess you wouldn’t need regexp or anything if you have these values already just concatenate them with a ‘-’ between them and assign that as the file name. You could do it with regexp, if the artist, album, and title were all contained in some output you could format it into artist-album-title but there isn’t a need if you already have the information and can just string it all together. Regexp would be better for much more complicated things. Like changing ‘The Baetles’ to 'The Beatles" wherever it exists over the entire library.

Right I think this is my point really from the users perspective you are saying you dont need regexp for this, but I need to provide an interface for them to decide which fields they want in the mask so regexp on its own isnt the answer.

But the good news is now we support Javascript Expressions, we also support Regular Expressions, for example this is is now a valid mask in Jaikoz

album.replace(/Boy/g,'Girl')