INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Trouble with isempty formula  (Read 2491 times)

Sangie

  • Recent member
  • *
  • Posts: 45
Trouble with isempty formula
« 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?
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Trouble with isempty formula
« Reply #1 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])
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

Sangie

  • Recent member
  • *
  • Posts: 45
Re: Trouble with isempty formula
« Reply #2 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.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Trouble with isempty formula
« Reply #3 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

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Trouble with isempty formula
« Reply #4 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
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

Sangie

  • Recent member
  • *
  • Posts: 45
Re: Trouble with isempty formula
« Reply #5 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.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Trouble with isempty formula
« Reply #6 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?
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner
Pages: [1]   Go Up