INTERACT FORUM

More => Old Versions => JRiver Media Center 24 for Mac => Topic started by: Sangie on October 16, 2018, 06:26:57 pm

Title: Trouble with isempty formula
Post by: Sangie on October 16, 2018, 06:26:57 pm
I'm trying to only make a folder for Album if the image file (I'm sorting images) has an album. All images have an artist associated.

So if an image has an album, it will be /Genre/Artist Name/Album Name/file name.ext
If no album, the path will be /Genre/Artist Name/file name.ext

Here is the formula I'm using.
Code: [Select]
[Genre]/[Artist]/if(isempty([Album],1),,[Album])Where did I screw up?
Title: Re: Trouble with isempty formula
Post by: RoderickGI on October 16, 2018, 07:08:30 pm
You are doing a numerical test in the isempty command. [Album] is, naturally, a String. Do a string test on it.


Code: [Select]
[Genre]/[Artist]/if(isempty([Album],0),,[Album])
Title: Re: Trouble with isempty formula
Post by: Sangie on October 17, 2018, 01:41:47 am
Thank you! I tried that though and now it says "Unknown Album" in the path. I copy pasted exactly what you put. Album is completely empty. I'm not sure what's wrong. I attached a screenshot.
Title: Re: Trouble with isempty formula
Post by: marko on October 17, 2018, 10:47:39 am
The ",0" needs to be inside the field tag... Like so... [Album,0]

Why? You're asking MC to create a path to a file, and operating systems don't like/allow folders with no name, so, only when using the 'rename' tool, if a field is empty, potentially creating a nameless folder, the rename tool fills it with "Unknown field name" before handing it over to the expression evaluator, meaning that, as far as the evaluator is concerned, the field is not empty. inserting the ",0" inside the field name tells all involved to use the raw field data 'as-is', so then, empty, really means, empty :)

-marko
Title: Re: Trouble with isempty formula
Post by: RoderickGI on October 17, 2018, 07:18:08 pm
Hey. I answered that last night. I must have forgotten to click Post after all the Previews I did!  :(

Or I got Administratored, because I did waffle on a bit.  ;D

So yeah, the full expression is;
Code: [Select]
[Genre]/[Artist]/if(isempty([Album,0],0),,[Album])
Nice explanation Marko. The reference is the Fields section here Sangie: https://wiki.jriver.com/index.php/Expression_Language
Title: Re: Trouble with isempty formula
Post by: Sangie on July 01, 2019, 04:52:12 pm
I'm so sorry I never updated this but this worked great. The example in the wiki did not which is weird:
https://wiki.jriver.com/index.php/IsEmpty()

Code: [Select]
ifelse(!isempty([disc #]), [disc #])Outputs the value of the disc # field when it is not empty.

I tried substituting Disc # with Album. Maybe it's because it was a string as mentioned above.
Title: Re: Trouble with isempty formula
Post by: RoderickGI on July 01, 2019, 08:34:47 pm
Yep, it is because Album is a string, and Disc # is not.

Also, that example uses "ifelse" rather than "if", so different parameters and outputs. Similar results though.

But it is all fixed and working now, right?