1.
You can check if the file is a subtitle, and then yield different values accordingly:
Code: Select all
f.subtitle ? ".this.is.a.subtitle" : null
Code: Select all
ext =~ /idx/ ? ".this.is.an.idx.file" : null

NOTE:
String.match() DOES NOT work the way you think. You can't use it as a boolean expression, since it'll either return a match or
throw an exception, but never return null.
Best to prototype with the Format Editor GUI so you get instant feedback.
2.
Conceptually, these two expressions are completely different, although I guess they might give you the same value.
This is 1 groovy expression, that contains 1 function call, that gets passed in 5 closures as arguments:
Code: Select all
{
allOf
{ac}
{channels}
{vf}
{source}
{vc}
}
So you can do things like this:
Code: Select all
{
def values = allOf{ac}{channels}{vf}{source}{vc}
values*.upper()*.removeAll(/\W/).join('-')
}

What is the difference between
def values = allOf{ac}{channels}{vf}{source}{vc} and
def values = [ac, channels, vf, source, vc] you may ask. And the answer is again the previously linked unwind-on-undefined behaviour, because if we access a undefined variable, our expression will unwind, unless we catch that exception, and
allOf(Closure...) and
any(Closure...) do just that for each closure that is passed in.
This is 5 groovy expressions, each of which does nothing but reference a variable:

NOTE: Semantically, the outermost {...} are completely different from any other {...} within the outermost {...} since the outermost {...} merely delimit Groovy code, which itself uses {...} for code blocks, closures, etc.