if-then-else structure not working

Any questions? Need some help?
Post Reply
vriesnet
Posts: 2
Joined: 29 Jan 2019, 13:42

if-then-else structure not working

Post by vriesnet » 29 Jan 2019, 14:02

I created the following format for Movies:

Code: Select all

Movies/{collection ? {"${collection}/${y}.${n.colon("|")}/${collection.replace(" Collection","")}[${ci}]."} : {"${ny.colon("|")}/"}}{ny.colon("|")}{".${lang}"}
Result when Movie is in Collection:
Movies/Avatar Collection/2009.Avatar/Avatar[1].Avatar (2009).mkv

Expected result when Movie is not in Collection (else-part):
Movies/Avatar (2009)/Avatar (2009).mkv

Actual result when Move is not in Collection:
Movies/Avatar (2009.mkv

Conclusion:
Movies that are part of a collection are processed ok. :)
The expected else-part of the format (when Movie is not part of a collection) is however omitted in the resulting filename. :?:

When I test the format in the Windows application with an optional if-statement "(collection == null)" the result of the else-part is formatted ok (on screen that is).
What am I doing wrong?

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

Re: if-then-else structure not working

Post by rednoah » 29 Jan 2019, 14:16

Here's an example that works for both cases:

Code: Select all

Movies/
{
    any{collection / "$y.$n" / collection.before('Collection') + "[$ci]."}
       {ny + '/'}
}
{plex.name}

Here's an explanation of how and why it works:
viewtopic.php?f=5&t=1895


:idea: collection == null doesn't work because {collection} is never null because instead of returning with a null value, it'll throw an error.
:idea: Please read the FAQ and How to Request Help.

vriesnet
Posts: 2
Joined: 29 Jan 2019, 13:42

Re: if-then-else structure not working

Post by vriesnet » 29 Jan 2019, 14:35

Wow, thanks for your quick response!
Your suggestion works as expected.

Post Reply