Page 1 of 1

Pass Source as a parameter

Posted: 24 May 2015, 09:41
by boranblok
Hello, I am writing a bit of automation to rename files.

I was wondering if it is possible to define source as a parameter (using --def) or defining another parameter and checking on that inside the script.

FileBot deals fine with files containing a source in the filename (BD, HDTV, etc) but I'd like to be able to pass this as an argument when the filename does not contain these.

Is this possible ?

Thanks in advance.

Re: Pass Source as a parameter

Posted: 24 May 2015, 10:20
by rednoah
I'm not sure what you wanna do, but there is plenty of ways to pass variables into your format:

You can access environment variables from your format:

Code: Select all

{System.env.SOURCE}
You can also build the format string in your Groovy code using your variables:

Code: Select all

'{n} [' + source + ']'
(assuming you have declared source)

The format actually has access to the cmdline --def variables via {defines} binding:

Code: Select all

{n} {defines.source}

Re: Pass Source as a parameter

Posted: 26 May 2015, 08:22
by boranblok
Thanks,

that helped a lot, now I can specify/override source using a def statement on the commandline.

This is about what the format statement looks like now:

Code: Select all

{n.ascii().space('.')}.{episode.special ? 's00e'+special.pad(2) : s00e00}.{t.ascii().space('.')}.{defines.source ? defines.source : source}.{vf}.{vc}{video.BitDepth = 10 ? '.Hi10p' : ''}.{ac}{audios.Language.size() > 1 ? (audios.Language.size() > 2 ? '.ML' : '.DL') : ''}{'-'+group}

Re: Pass Source as a parameter

Posted: 26 May 2015, 09:02
by rednoah
Shorter is better:

Code: Select all

{defines.source ?: source}
== is equals, = is assignment; video.BitDepth will return a String value:

Code: Select all

{video.BitDepth == '10' ? '.Hi10p' : ''}