Page 1 of 1

Use French Title for French movies but English title for other movies

Posted: 31 Jan 2022, 07:37
by coupcoup
Hi,

I have a huge media library and until now I was renaming everything manually. I've just discovered FileBot, which seems to be my life savior. Unfortunately, I'm a complete newbie regarding scripting and groovy, and I'm facing issues I have not been able to solve for now, even after days of search.

I've installed FileBot 4.9.4 on my Windows 10 computer, and I've used bit of codes coming from this forum. I think I have now a good understanding about how it works, and everything is OK as long as I stick with the basic FileBot bindings ({af}, {vc}, etc.). But when I'm trying to use some more "advanced" scripting (meaning using Groovy functions, if I'm not mistaken), I'm getting errors.

For example, a very simple script like this one:

Code: Select all

{norm(primaryTitle)}

gives me (on "The Disaster Artist" folder):

Code: Select all

[No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.norm() is applicable for argument types: (String) values: [The Disaster Artist]
Possible solutions: eval(java.lang.String), get(java.lang.String), notify(), wait(), dump(), find()] The Disaster Artist (2017)
I'm sure that I'm missing some basic thing, but I can't find what. Will it be possible to help me before I lose my mind?

Here is my sysinfo. Should I share some more info from my system and filebot installation?

Code: Select all

FileBot 4.9.4 (r8736)
JNA Native: 6.1.0
MediaInfo: 20.09
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2022-01-20 (r791)
Groovy: 3.0.8
JRE: OpenJDK Runtime Environment 16.0.2
JVM: OpenJDK 64-Bit Server VM
CPU/MEM: 16 Core / 8 GB Max Memory / 678 MB Used Memory
OS: Windows 10 (amd64)
STORAGE: NTFS [(C:)] @ 778 GB | NTFS [Films 4k] @ 192 GB | NTFS [Games] @ 57 GB | FAT32 [Google Drive] @ 2.0 GB | exFAT [My Book] @ 1.3 TB
DATA: C:\Users\Coupcoup\AppData\Roaming\FileBot
Package: MSI
License: UNREGISTERED

Re: Need help with functions not working

Posted: 31 Jan 2022, 07:45
by rednoah
There is no such function, thus you get a "No signature of method" error.


:?: What do you want your newly proposed norm() function to do?


:idea: You have likely copied norm() from some custom code snippet. That snippet will have defined that function first, and then used it later in multiple places. If you only copy the usage, then it won't work.


:idea: I would generally discourage complex format code, classes, functions, etc; just because you can do anything doesn't mean you have to overcomplicate things, especially if your format doesn't exceed a couple of lines. ;)

Re: Need help with functions not working

Posted: 31 Jan 2022, 16:16
by kim

Code: Select all

{def norm = {it.replaceAll(/(?i)[abcde]/)}; norm(n) + ' vs ' + n}
sample:
Th isstr rtist vs The Disaster Artist
only use if you need to do the same thing multiple times within a

Code: Select all

{}

Re: Need help with functions not working

Posted: 31 Jan 2022, 23:46
by coupcoup
Thank you so much for your help! I feel like a complete idiot for not having understood it by myself... :oops:

When I'm trying something like that (before moving forward to a more complex norm() function):

Code: Select all

{def norm = {it.upperInitial().replaceTrailingBrackets()};{info.OriginalLanguage != /fr/ ? norm(n) : norm(primaryTitle)}}
I'm getting this error:

Code: Select all

SyntaxError: Ambiguous expression could be either a parameterless closure expression or an isolated open code block;
   solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...}
Can you please help with that?

Re: Need help with functions not working

Posted: 01 Feb 2022, 01:53
by rednoah
Correct but unnecessarily complicated:

Code: Select all

{
	def norm = {
		it.upperInitial().replaceTrailingBrackets()
	}

	info.OriginalLanguage != /fr/ ? norm(n) : norm(primaryTitle)
}

Correct and readable:

Code: Select all

{
	def frenchTitle = info.OriginalLanguage != /fr/ ? n : primaryTitle
	frenchTitle.upperInitial().replaceTrailingBrackets()
}

Correct and readable as single line without variables:

Code: Select all

{
	(info.OriginalLanguage != /fr/ ? n : primaryTitle).upperInitial().replaceTrailingBrackets()
}