[SNIPPET] Sort Name

All about user-defined episode / movie format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 14942
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[SNIPPET] Sort Name

Post by rednoah » 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. :!:
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests