[SNIPPET] Sort Name
Posted: 31 Jul 2012, 06:15
Sometimes it may be useful to put the The or an A that many movie names begin with (e.g. The Avengers) at the end of the name (i.e. Avengers, The) to improve lexical sort order. You can do that in your custom format, either via the String.sortName() helper method or some custom regex replace.
The Avengers => Avengers
The Avengers => Avengers, The
The Avengers => A
Custom Regex Replace:
Note that most software expects the file name and the database entry to match exactly. If you mess up the file name like this, then FileBot and any other 3rd party software may have trouble making sense of the file name in the future. 
The Avengers => Avengers
Format: Select all
{ n.sortName() }
The Avengers => Avengers, The
Format: Select all
{ n.sortName('$2, $1') }
The Avengers => A
Format: Select all
{ n.sortName()[0] }
Custom Regex Replace:
Format: Select all
{ n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/) }

