Page 1 of 1
Movie format: Colons and Articles (The, A, An...)
Posted: 20 May 2019, 15:24
by eptesicus
Looking to properly format movies to be in the example format, "Lion King 2, The - Simba's Pride (1998).mkv". My format expression is below. In my expression, it results in the article, the, a, and an to be before the year, but not before the colon/hyphen like "Lion King 2 - Simba's Pride, The (1998). Is there a way for the expression to be altered to move the leading The, An, or A to before the colon/hyphen?
Code: Select all
{n.colon(' - ').replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)} {'('+y+')'}
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 20 May 2019, 15:42
by rednoah
e.g.
Code: Select all
{ny.split(':')*.sortName('$2, $1').join(' - ')}
Code: Select all
Lion King 2, The - Simba's Pride (1998)

Note that this won't work well for contrived corner cases like
The Name: The Title where both
The would be shuffled around, and not just the first one.
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 20 May 2019, 18:23
by eptesicus
rednoah wrote: ↑20 May 2019, 15:42
e.g.
Code: Select all
{ny.split(':')*.sortName('$2, $1').join(' - ')}
Code: Select all
Lion King 2, The - Simba's Pride (1998)

Note that this won't work well for contrived corner cases like
The Name: The Title where both
The would be shuffled around, and not just the first one.
Interesting... With that, I get output like below. So it appears to work exactly how I want
unless there is no colon/hyphen.
Code: Select all
Chronicles of Narnia, The - The Voyage of the Dawn Treader (2010).mkv
Chronicles of Narnia, The - Prince Caspian (2008).mkv
Chronicles of Riddick (2004), The.mkv
Matrix (1999), The.mkv
Quiet Place (2016), A.mkv
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 20 May 2019, 18:25
by rednoah
Fixed:
Code: Select all
{n.split(':')*.sortName('$2, $1').join(' - ')} ({y})
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 20 May 2019, 18:32
by eptesicus
rednoah wrote: ↑20 May 2019, 18:25
Fixed:
Code: Select all
{n.split(':')*.sortName('$2, $1').join(' - ')} ({y})
Thanks! I just figured that out before hopping back on here. Thanks for your help!
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 30 Jun 2019, 16:21
by tresi
May I ask a follow-up question here that is very similar to the opening question? Otherwise, please move it to a new post.
I would like to rename files with an article at the beginning in such a way that it is deleted at the beginning and appended by comma at the end again, i. e.
The Addams Family -> Addams Family, The
The pattern {n.match('^(The|An|A|Der|Die|Das|Eine|Ein|Une|Un) '} matches the beginning and with {n.replaceFirst'^(The|An|A|Der|Die|Das|Das|Eine|Ein|Une|Un) '} I can remove the beginning but I don't know how to get everything together and get a backreference of the matched article at the end.
I hope it's reasonably understandable what I'm going to do

Re: Movie format: Colons and Articles (The, A, An...)
Posted: 30 Jun 2019, 20:46
by kim
this only removes
Code: Select all
{n.replaceFirst'^(The|An|A|Der|Die|Das|Das|Eine|Ein|Une|Un) '}
you need the "\s(.+)/, /$2, $1/)" part
now
($1)($2)
after
$2, $1
e.g. (not tested)
Code: Select all
{n.replaceFirst(/^(?i)(The|An|A|Der|Die|Das|Eine|Ein|Une|Un)\s(.+)/, /$2, $1/)} {'('+y+')'}
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 03 Jul 2019, 15:38
by tresi
@kim: Thanks for your reply. Unfortunately your code results in an empty filename with the year in brackets only.
i. e. "The Addams Family (2000)" -> " (2000)"
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 03 Jul 2019, 15:50
by rednoah
It works for me. I'm using the Format Editor. If you're using the CLI, then you might need to take special care of command-line things like $ ' " etc.

What exactly are you doing?
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 04 Jul 2019, 02:50
by tresi
Concrete example:
Code: Select all
filebot --db TheTVDB --action test --lang de -no-xattr -non-strict --format "/media/Video/Serien/{n =~ /^(?i)[a-z]/ ? n[0] : '#'}/{n.replaceFirst(/^(?i)(The|An|A|Der|Die|Das|Eine|Ein|Une|Un)\s(.+)/, /$2, $1/)} {'('+y+')'}/Staffel {s.pad(2)}/{n} - {s00e00} - {t}" -rename /tmp/themaninthehighcastle.s01e01.720p.german.mkv
Output:
Code: Select all
Illegal Argument: java.nio.file.NoSuchFileException: /tmp/themaninthehighcastle.s01e01.720p.german.mkv (/tmp/themaninthehighcastle.s01e01.720p.german.mkv)
Rename episodes using [TheTVDB]
Auto-detected query: [The Man in the High Castle, themaninthehighcastle]
Fetching episode data for [The Man in the High Castle]
[TEST] from [/tmp/themaninthehighcastle.s01e01.720p.german.mkv] to [/media/Video/Serien/T/, (2015)/Staffel 01/The Man in the High Castle - S01E01 - Die neue Welt.mkv]
Processed 1 files
The first line "Illegal Argument..." is already unexpected. I copied the file for testing issues to temp and i have full access to it. With TAB in the shell it is self-expanded. This error message don't show up if the file is outside the /tmp dir. Via mv "file" ~/Downloads/ it is working but the renaming result is the same.
Expected result:
Move to [/media/Video/Serien/M/Man in the High Castle, The (2015)/Staffel 01/The Man in the High Castle - S01E01 - Die neue Welt.mkv]
I know that I have to change the letter with the first letter of the new name in the path after .../Serien/... but this will be the next step.
Thanks a lot in advance
Best regards,
tresi
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 04 Jul 2019, 03:20
by rednoah
The format you think you're passing in, isn't the format you're actually passing in, because of the shell interpreter.

Please read
Cmdline and Argument Passing to understand the problem.

Just use the
@file syntax for reading command-line arguments from external text files, to avoid this kind of problem altogether.
Re: Movie format: Colons and Articles (The, A, An...)
Posted: 19 Jul 2019, 14:22
by tresi
Sorry I didn't get back to you until now. I had a lot to do and also tried a lot with Filebot. Unfortunately I didn't make it. The effort is too big for me at the moment, so I leave it as it is. Nevertheless many thanks for the help
Many greetings, tresi