Page 1 of 1

[SNIPPET] Sort Name

Posted: 31 Jul 2012, 06:15
by rednoah
Sometimes it's useful to put the "The" or an "A" that many movie names begin with (e.g. The Avengers) at the end of the name (Avengers, The) to improve lexical sort order. It's easy to do that in the format via an regular expression replace.


The Avengers => Avengers

Code: Select all

{n.sortName()}
The Avengers => Avengers, The

Code: Select all

{n.sortName('$2, $1')}
Groovy code:

Code: Select all

{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
:!: If you mess up the filename like this, FileBot and HTPC software may have trouble making sense of the filename in the future. :!:

Re: [SNIPPET] Sort Name

Posted: 23 May 2019, 15:31
by jasonsmith
rednoah wrote:
31 Jul 2012, 06:15
Sometimes it's useful to put the "The" or an "A" that many movie names begin with (e.g. The Avengers) at the end of the name (Avengers, The) to improve lexical sort order. It's easy to do that in the format via an regular expression replace.


The Avengers => Avengers

Code: Select all

{n.sortName( )}
The Avengers => Avengers, The

Code: Select all

{n.sortName('$2, $1')}
Groovy code:

Code: Select all

{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
:!: If you mess up the filename like this, FileBot and HTPC software may have trouble making sense of the filename in the future. :!:
i didn't thought this way before, thanks for sharing.myanimelsit mathway birthday wishes