Running FileBot from the console, Groovy scripting, shell scripts, etc
cemmec
Posts: 7 Joined: 18 Apr 2015, 03:54
Post
by cemmec » 09 Mar 2016, 01:40
Hi,
I am new to scripting but could find some samples that are working fine to me. But I have on doubt with the following part:
Code: Select all
{"["}{def a= [];"[$media.Audio_Codec_List]".contains("DTS") ? a.add("DTS") : "";"[$media.Audio_Codec_List]".contains("AC3") ? a.add("AC3") : "";"[$media.Audio_Codec_List]".contains("MPEG-1 Audio layer 3") ? a.add("MP3") : "";a.join("+")}{"]"}
In this case if I have a DTS or AC3 on any other condition, the result is: [DTS] or [DTS+AC3] or [AC3] otherwise the result is []. I would like to have nothing as a result not []. I know that {"["} and {"]"} are returning this, but how can I make a condition with it?
rednoah
The Source
Posts: 23941 Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:
Post
by rednoah » 09 Mar 2016, 03:59
I'd do it like this:
Code: Select all
{audios.codec.collect{ it[0, 1, -1] }.join('+') ?: ''}
rednoah
The Source
Posts: 23941 Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:
Post
by rednoah » 09 Mar 2016, 06:02
FileBot r3639+ makes this easier:
Add prefix/suffix:
Code: Select all
{audios.codec.collect{ it[0, 1, -1] }.join('+', '[', ']')}
Unwind-on-empty behaviour:
cemmec
Posts: 7 Joined: 18 Apr 2015, 03:54
Post
by cemmec » 09 Mar 2016, 23:37
Did not find version r3639 on
https://sourceforge.net/projects/filebo ... ebot/HEAD/ I'm using r3315, which I think is the latest stable version.
Where can I download r3639 ?
On version r3315 I couldn't add prefix and sufix on {audios.codec.collect{ it[0, 1, -1] }.join('+') ?: ''}
cemmec
Posts: 7 Joined: 18 Apr 2015, 03:54
Post
by cemmec » 10 Mar 2016, 20:03
Nevermind... it's working...
Thanks one more time!