Page 1 of 1

Ternary operator within drive picking snippet?

Posted: 16 Jun 2020, 11:14
by AbedlaPaille

Code: Select all

{['C:', 'D:', 'E:'].collect{ (it+'/TV/'+n) as File }.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{episode}
Glorious snippet. I'm trying to troubleshoot an issue though, maybe you can help me.

I've modified it slightly because my TV shows names are bilingual :

Code: Select all

{['D:', 'E:'].collect{ (it+'/TV/'+info.network =~ (/Canal+|Arte|OCS|France 4/) ? localize.French.n : n) as File }.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}
It works but only on files that exist on D: or E: specified paths.
For the ones that are on my C: drive Filebot shows this.
When i remove the ternary operator it works fine for those C: files. The same ternary operator works well outside of this snippet too. What am i missing?

Re: Ternary operator within drive picking snippet?

Posted: 16 Jun 2020, 12:36
by rednoah
I'd add parenthesis just to make clear what's going on:

Code: Select all

(it + '/TV/' + (info.network =~ (/Canal+|Arte|OCS|France 4/) ? localize.French.n : n)) as File

Re: Ternary operator within drive picking snippet?

Posted: 16 Jun 2020, 12:53
by AbedlaPaille
Yep that's a winner, thanks a lot