How to put leading 'the' at the end of the title?

How-to guides, frequently asked questions, not-so-obvious features, etc
Post Reply
rainbow
Posts: 7
Joined: 21 Feb 2019, 19:53

How to put leading 'the' at the end of the title?

Post by rainbow » 13 Mar 2019, 14:43

I'm sure this has been asked a million times, but I didn't really find out how to do it...

So there's a number of things I want to move to the end of a movie title:
- the, a, an
- le, la
- der, die, das
...and, obvisouly, I want to end up with 'Sting, the' instead of 'The sting'.

Would it be possible to have all this stuff in a small little .txt-file, so it doesn't clutter up my format expression?

right now my expression looks like this:

Code: Select all

{n.colon(":")} [{y} - {director.replaceFirst(/(\w)(\w+) (\w+)/, '$1. $3')} - {(minutes/60) as int}h{minutes-(((minutes/60) as int)*60)}m - {genres.take(3).join(', ')} - {actors.take(2)*.replaceFirst(/(\w)(\w+) (\w+)/, '$1. $3').join(', ')} - {fn.matchAll(/deutsch|deu|english|eng|french/).join()} - {rating}]
Oh, and (completely unrelated): Is it possible to have a multi-line editor for this expression in filebot? Or is it always just one line, and if my expression gets more complex its best to use another editor and copy/paste into filebot?

User avatar
rednoah
The Source
Posts: 16434
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to put leading 'the' at the end of the title?

Post by rednoah » 13 Mar 2019, 14:58

1.
String.sortName() does it for English, but for other languages you'll need to pass in the regex pattern yourself:
viewtopic.php?f=5&t=211

Code: Select all

n.sortName('$2, $1')

2.
Since you are writing Groovy code, you can use Groovy to read files.

e.g.

Code: Select all

("/path/to/file" as File).text

If it's just a few regular expressions you wanna maintain elsewhere, then you can also use environment variables:

Code: Select all

System.getenv('MY_ENV_VAR')
:idea: Please read the FAQ and How to Request Help.

Post Reply