Page 1 of 1

[EVAL] Split code into external *.groovy script files

Posted: 24 May 2019, 11:27
by rednoah
1.
These two format expressions are equivalent:

Code: Select all

{plex.name}

Code: Select all

{evaluate('plex.name')}

Code: Select all

{evaluate('/path/to/code.groovy' as File)}

2.
This approach can be used to refactor complex formats into one or more reusable components and split them into external *.groovy script files:

Code: Select all

{include '/path/to/TargetFolder.groovy'}
{include '/path/to/MovieNaming.groovy'}
{include '/path/to/MediaInfoTags.groovy'}

Code: Select all

{include "/path/to/MovieFormat.${y > 1980 ? 'Recent' : 'Classic'}.groovy"}
:arrow: groovy.lang.Script
:arrow: net.filebot.format.ExpressionFormatFunctions