Pass Source as a parameter

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
boranblok
Posts: 2
Joined: 24 May 2015, 09:38

Pass Source as a parameter

Post 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.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pass Source as a parameter

Post 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}
:idea: Please read the FAQ and How to Request Help.
boranblok
Posts: 2
Joined: 24 May 2015, 09:38

Re: Pass Source as a parameter

Post 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}
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pass Source as a parameter

Post 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' : ''}
:idea: Please read the FAQ and How to Request Help.
Post Reply