Page 1 of 1

Batch pre-processing files to help with auto-detection

Posted: 18 Aug 2017, 16:11
by tng5737
I am running FileBot under Windows 10 Home and am trying to rename movie files. The original filenames have a pattern of 'yyyy - name.ext' I want to rename them to this: 'name (yyyy).ext and have set a preset of '{n} ({year})' The problem is that in order to rename you have to do a Fetch first but the movie db will not recognize the file in its original format, therefore no Rename is performed. How can I get my files renamed?
Also sometimes the titles have a fixed text included in the names - these texts contain spaces or dashes. I would like to remove those fixed texts from the title. (ie, '1922 - Laugh-O-Grams - Little Red Riding Hood.avi' --> 'Little Red Riding Hood (1922)'

Re: Problem with Rename

Posted: 18 Aug 2017, 16:40
by rednoah
You could batch rename files without matching them:
viewtopic.php?f=3&t=2072

Example 1:

Code: Select all

{fn.after('-')} ({fn.before('-')})
Example 2:

Code: Select all

{fn.split('-', 2).reverse().join(' - ')}
Example 3:

Code: Select all

{'1922 - Laugh-O-Grams - Little Red Riding Hood'.split(' - ')[-1, 0].join(' - ')}

Re: Batch pre-processing files to help with auto-detection

Posted: 18 Aug 2017, 17:18
by tng5737
Thank you for the quick reply. I have a couple of questions.
When moving the year to the end and removing the unwanted fixed text - is this a multi-step process? Move 'year' and then remove 'text'?
Is there a place were the various functions are explained (like, fn.split)?

Re: Batch pre-processing files to help with auto-detection

Posted: 18 Aug 2017, 17:28
by rednoah
1.
No, you'd simply transform A - B - C into C - A in one single rename operation. You could then process with TheMovieDB in a second operation to properly organize the file according to the {plex} format.


2.
Format expressions are running within the context of FileBot / Groovy / Java so you will have access to tens of thousands of methods and classes and you will find full documentation for all of that online, for example the docs for the String.split() method.

A simple Groovy tutorial will probably be more helpful than technical documentation of all classes and methods though. ;)

Re: Batch pre-processing files to help with auto-detection

Posted: 18 Aug 2017, 19:01
by tng5737
Sorry to bother you but I can't get this to work. Here are my steps:
1) Select my file: '1922-Laugh-O-Grams - Little Red Riding Hood' and drag it to the Original Files area
2) Click on 'New Names' area to give focus then right-click and select 'Edit Format'
3) In the Expression area - enter '{n} ({y})' and select 'Use Format' (trying to keep it simple)
4) Click back in 'New Names' are and hit F2
The file is not renamed and is identical to the original file name. Nothing is renamed
What am I missing? I watched your Renaming tutorial on YouTube but you did everything so fast I couldn't figure out what you were doing.

Re: Batch pre-processing files to help with auto-detection

Posted: 18 Aug 2017, 21:41
by tng5737
I sort of got it to work by using this expression: {fn.after('Laugh-O-Grams - ')} ({fn.before('-')})
However doing it this way requires my editing the 'Laugh...' text for every different form of fixed text in my file list (ie 'Alice Comedies' etc...
Is there a way to remove ANY fixed text from the pattern of 'yyyy - fixed text - title.ext ? What I need is just the 'title.ext (yyyy)'

Re: Batch pre-processing files to help with auto-detection

Posted: 19 Aug 2017, 03:16
by rednoah
Yes. That's what Example 3 does:

Code: Select all

{fn.split(' - ')[-1, 0].join(' - ')}
Take the filename, split it by " - " into columns, then take the last column (movie name) and the first column (year) and join them together to generate the new name.

e.g. 2000 - blablabla yaddayadda - MovieMovie - 2000

Re: Batch pre-processing files to help with auto-detection

Posted: 20 Aug 2017, 02:33
by tng5737
Thanks - I ended up doing it in two passes. First moved the year to the end and the second pass just threw out everything up to and including the ' - ' I bought a couple of books about regular expression so I can learn how to do this without bothering you!

Re: Batch pre-processing files to help with auto-detection

Posted: 20 Aug 2017, 03:18
by rednoah
Regular Expressions are useful for this kind of task. However, I didn't use regular expressions at all, and opted for more simple Java/Groovy code instead. ;)

Re: Batch pre-processing files to help with auto-detection

Posted: 27 Dec 2022, 12:17
by rednoah