INTERACT FORUM

Please login or register.

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

Author Topic: IfEmpty not working  (Read 1124 times)

aaronsama

  • Recent member
  • *
  • Posts: 14
IfEmpty not working
« on: December 27, 2014, 08:38:50 am »

Can someone tell me what I'm doing wrong? I'm trying to get JRiver to auto-name all my files differently depending on whether there is a value in the [Disc #] field. Specifically, where there is no [Disc #], I want it to use PadNumber([Track #],3) so that the tracks list out as 001, 002, 003, etc. (I have some digital albums with 100+ tracks). If there is a value in the [Disc #], I want it to use PadNumber([Disc #],2)-PadNumber([Track #],2) so it lists out as 01-01, 01-02. This will allow legacy MP3 players, burned MP3 CDs, etc. that go in order by filename to play in the correct order.

In order to do this, I've constructed an expression to test for whether there is a value in the [Disc #], and depending on whether it is empty, use the appropriate expression:

If(IsEmpty([Disc #]),PadNumber([Track #],3),PadNumber([Disc #],2)-PadNumber([Track #],2))-[Name]

The problem is, when [Disc #] is empty, it treats it as [Disc #] = Unknown Disc, so I get Unknown Disc -01, Unkown Disc -02, instead of 001, 002.

When I use If(IsEqual([Disc #],Unknown Disc) ... that fails as well. Any hints here?

-Aaron
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8972
Re: IfEmpty not working
« Reply #1 on: December 27, 2014, 09:33:55 am »

When using the rename tool, add a zero to instruct the tool to use the raw data, like so...

If(IsEmpty([Disc #,0]),PadNumber([Track #],3),PadNumber([Disc #],2)-PadNumber([Track #],2))-[Name]

Here's an explanation I posted earlier this year...

Re: isempty()...

If you imagine asking MC to create a directory structure using [series] without first testing its 'emptiness', and it was empty, MC would be attempting to create a directory with no name, which is not good. For this reason, if the field is actually empty, the rename tool replaces the emptiness with "Unknown [field]", and it does this before handing things over to the expression evaluator, meaning that as far as its concerned, the field is not empty.

You can use the same method to turn this off, ie...
You just need to be careful you're not asking MC to create illegal file paths or names, although in my testing, MC appears to gracefully and quietly correct any illegal double backslashes that appear in the new path, so you just lose a level in the path, which might not be what you want, but would be easy to correct.

regards,
marko

aaronsama

  • Recent member
  • *
  • Posts: 14
Re: IfEmpty not working
« Reply #2 on: December 27, 2014, 10:39:39 am »

Thank you! The explanation makes sense, and it works like a charm.

-Aaron
Logged
Pages: [1]   Go Up