Help on scripting

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
cemmec
Posts: 7
Joined: 18 Apr 2015, 03:54

Help on scripting

Post by cemmec »

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

Re: Help on scripting

Post by rednoah »

I'd do it like this:

Code: Select all

{audios.codec.collect{ it[0, 1, -1] }.join('+') ?: ''}
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23093
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help on scripting

Post by rednoah »

FileBot r3639+ makes this easier:

Add prefix/suffix:

Code: Select all

{audios.codec.collect{ it[0, 1, -1] }.join('+', '[', ']')}
Unwind-on-empty behaviour:

Code: Select all

{[].join('+', '[', ']')}
:idea: Please read the FAQ and How to Request Help.
cemmec
Posts: 7
Joined: 18 Apr 2015, 03:54

Re: Help on scripting

Post by cemmec »

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

Re: Help on scripting

Post by cemmec »

Nevermind... it's working...

Thanks one more time!
Post Reply