Custom Sort Name

All about user-defined episode / movie / file name format expressions
Post Reply
njf
Posts: 15
Joined: 29 Jun 2017, 23:04

Custom Sort Name

Post 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'?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: [SNIPPET] Sort Name

Post 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}
njf
Posts: 15
Joined: 29 Jun 2017, 23:04

Re: [SNIPPET] Sort Name

Post 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.
nuckles
Posts: 2
Joined: 22 Dec 2017, 00:41

Re: [SNIPPET] Sort Name

Post 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
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Custom Sort Name

Post by kim »

Post Reply