Page 1 of 1

How to match "year - director - moviename.ext"

Posted: 28 Jul 2020, 10:20
by MagnusDaMan
Hi.
I am trying to figure out how to do the matchings for movies.
I have worked with regular expressions in two other programming languages, but find this very hard.

All my movies are in the format of "1984 - James Cameron - Peace and Love.mkv".
If I want to have the result "Peace and Love (1984)", I need to somehow identify the director name and then ignore it,or don't I?
I have tried to use the fn.after, but I can't figure out how to match after the second " - ".
In the "Format expressions" page https://www.filebot.net/naming.html I found that there is a function names "di", but I can't figure out how to use it.
And I'm not even sure if this is the way to go.

Any help would be greatly appreciated.

Re: How to match "year - director - moviename.ext"

Posted: 28 Jul 2020, 11:40
by rednoah
Use Plain File Mode to pre-process your files into nice Name (Year) patterns first before matching them against TheMovieDB in a second step:

Code: Select all

{fn.after(" - ").after(" - ")} ({fn.before(" - ")})

Re: How to match "year - director - moviename.ext"

Posted: 28 Jul 2020, 11:46
by MagnusDaMan
Oh yes!

Thank you!
As usual, when you see the solution, you think "Oh, it was that easy...".
It would have taken me some time to figure that one out though.

Works like a charm!
Thanks a lot.

Re: How to match "year - director - moviename.ext"

Posted: 28 Jul 2020, 12:09
by kim
or with regex

Code: Select all

{fn.replaceAll(/(^(?:19|20)\d{2}) - (.+) - (.+)$/),'$3 ($1) - $2'}
Peace and Love (1984) - James Cameron

Re: How to match "year - director - moviename.ext"

Posted: 28 Jul 2020, 14:58
by rednoah
This also works quite nicely~ :lol:

Code: Select all

{fn.split('-', 3)[2,0].join(' ')}

Re: How to match "year - director - moviename.ext"

Posted: 29 Jul 2020, 12:39
by MagnusDaMan
After some testing neither of these work very well.
When I create a preset (Named Movies and set datasource to TheMovieDB) and try {fn.replaceAll(/(^(?:19|20)\d{2}) - (.+) - (.+)$/),'$3 ($1) - $2'}, then "11940 - Anatole Litvak - City for Conquest.avi" becomes "City for Conquest (1940) - Anatole Litvak".

When using the format {fn.split('-', 3)[2,0].join(' ')} in file mode it can't find anything, but sends up the popup "Please identify the following files".
(Just a question on the split. Is the number 3 the third part? Does this mean that the split is 1-based and not 0-based?)

It seems to me that the {fn.after(" - ").after(" - ")} ({fn.before(" - ")}) gets more matches than the other two do.

Re: How to match "year - director - moviename.ext"

Posted: 29 Jul 2020, 12:55
by kim
rednoah wrote: 28 Jul 2020, 11:40 Use Plain File Mode to pre-process your files into nice Name (Year) patterns first before matching them against TheMovieDB in a second step:

Code: Select all

{fn.after(" - ").after(" - ")} ({fn.before(" - ")})
MagnusDaMan wrote: 29 Jul 2020, 12:39 When I create a preset (Named Movies and set datasource to TheMovieDB) and try {fn.replaceAll(/(^(?:19|20)\d{2}) - (.+) - (.+)$/),'$3 ($1) - $2'}, then "11940 - Anatole Litvak - City for Conquest.avi" becomes "City for Conquest (1940) - Anatole Litvak".
this new filename works 100%, sounds like you don't do the 2 steps
1. rename using this format
2. match using an other format e.g.

Code: Select all

 {plex.tail}

Re: How to match "year - director - moviename.ext"

Posted: 29 Jul 2020, 19:50
by MagnusDaMan
Ok. That renaming works perfect if there is only the movie file itself. I removed the name of the director, since I don't need it. I want to add a library to it as well, so I changed it to:

Code: Select all

{fn.replaceAll(/(^(?:19|20)\d{2}) - (.+) - (.+)$/),'./$3 ($1)/$3 ($1)'}
and then it works perfect for one file.
But when I have subtitles as well, then each subtitle get's it's own folder as well, so that becomes very weird.

I have to understand this second step as well. I am using Emby, so I guess plex is not right (or is it?). And in which format would this be used? In the movie format?

Re: How to match "year - director - moviename.ext"

Posted: 30 Jul 2020, 03:21
by rednoah
1.
You'll need to adjust your format to account for subtitles as well. Please read How to Request Help if you need more specific help.


2.
{plex} will work just fine. Emby will be happy with standard Plex naming.