Ternary operator within drive picking snippet?

Any questions? Need some help?
Post Reply
AbedlaPaille
Posts: 90
Joined: 12 Apr 2020, 04:02

Ternary operator within drive picking snippet?

Post by AbedlaPaille » 16 Jun 2020, 11:14

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?

User avatar
rednoah
The Source
Posts: 18537
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Ternary operator within drive picking snippet?

Post by rednoah » 16 Jun 2020, 12:36

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

AbedlaPaille
Posts: 90
Joined: 12 Apr 2020, 04:02

Re: Ternary operator within drive picking snippet?

Post by AbedlaPaille » 16 Jun 2020, 12:53

Yep that's a winner, thanks a lot

Post Reply