Page 1 of 1

Custom Sort Name

Posted: 03 Jul 2017, 00:26
by njf
Hi

I am using the sortName to move the opening 'The' to the end of the name and have inserted it in brackets. However, I prefer to limit it to moving 'The' and not 'A' or 'An' because I have so few of these. I don't know whether the Groovy code can be amended to do that but unfortunately I do not understand its syntax.

How can I just move 'The' and not 'A' or 'An'?

Re: [SNIPPET] Sort Name

Posted: 03 Jul 2017, 02:06
by kim
Are you using the GUI ?
If not, DO IT!

You should try playing around with formats, by adding/deleting stuff
e.g. you use

Code: Select all

{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
some of it is filebot only, but mostly you can use java / groovy code...
and in this case also Regular expression https://en.wikipedia.org/wiki/Regular_expression

so try just to remove the part "|A|An" you know you dont want and then you get

Code: Select all

{n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)} 
DONE :)

PS: google the stuff you dont understand ;)

btw: I think my way is better, try this:

Code: Select all

{ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/)}
now the "MOVIE, The (YEAR)"

instead of "MOVIE (YEAR), The" that you get with

Code: Select all

{ny.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}
if you want to reverse it back to the front then try e.g. :

Code: Select all

{folder.name.replaceFirst(/^(.+),.(?i)(The|A|An)/, /$2 $1/)}/{fn}

Re: [SNIPPET] Sort Name

Posted: 03 Jul 2017, 11:42
by njf
Thank you. Using that enabled me to work out the expression I needed. Can I just check - when you refer to using the GUI, do you mean the one you see by editing the preset and clicking on the icon to the right of the Expression in the Preset Editor?

I have one more question for now but I will create a new thread as I haven't found the answer and it relates to a different aspect.

Re: [SNIPPET] Sort Name

Posted: 22 Dec 2017, 00:48
by nuckles
using your script above: {ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/)}

can you please add the code to replace colon (:) with dash ( - )

thank you

Re: Custom Sort Name

Posted: 23 Dec 2017, 18:28
by kim