INTERACT FORUM

Please login or register.

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

Author Topic: Using if... isequal... unknown when "Unknown" is in the path?  (Read 833 times)

dasfoo

  • Junior Woodchuck
  • **
  • Posts: 61
Using if... isequal... unknown when "Unknown" is in the path?
« on: August 14, 2020, 07:00:12 pm »

I use a few custom fields in my movie/TV library and then a bunch of "if..." statements in the path rule when moving files, in order to get the folder hierarchy I want, like:

Code: [Select]
if(isequal([Media Disk],unknown,8),,\[Media Disk])if(isequal([Media Share],unknown,8),,\[Media Share])if(isequal([Media Drive],unknown,8),,\[Media Drive])if(isequal([Grouping],unknown,8),,\[Grouping])if(isequal([Movie Title],unknown,8),,\[Movie Title])if(isequal([Series],unknown,8),,\[Series])if(isequal([Season],unknown,8),,\Season [Season])
In 99.99% of cases this works great. However, I have one movie that skips one of these conditions and ends up in the wrong place, and I think it's because the word "Unknown" is in the value of the field getting skipped. Is there a workaround for this?

(I tried inserting 7 random characters for "unknown" in the code above, which fixed this one field but broke how it handles all of the empty fields.)
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Using if... isequal... unknown when "Unknown" is in the path?
« Reply #1 on: August 14, 2020, 11:12:46 pm »

You'll have to provide more information if you want a diagnosis.

Code: [Select]
if(isequal([Media Disk],unknown,8),,\[Media Disk])if(isequal([Media Share],unknown,8),,\[Media Share])if(isequal([Media Drive],unknown,8),,\[Media Drive])if(isequal([Grouping],unknown,8),,\[Grouping])if(isequal([Movie Title],unknown,8),,\[Movie Title])if(isequal([Series],unknown,8),,\[Series])if(isequal([Season],unknown,8),,\Season [Season])

This expression structure is odd, but valid. I can see what it does.  I have no way of knowing if that's the same as what you want it to do.

I can tell you that doing a case insensitive negative substring search for the string "unknown" against [Movie Title] and [Series], in the way you are, is flawed, as it will fail to insert your path info for any video that contains that word in its actual title, and there are at least 200 such movies listed on IMDB, plus a lot of TV shows.  If that is your problem, the solution is for you not to use a common word, "unknown", to indicate a special condition in a field that might normally contain that word.  Why would the word "unknown" be in there in the first place? Either it's there naturally because it's part of the title, or some external program put it there, or you put it there.

In 99.99% of cases this works great. However, I have one movie that skips one of these conditions and ends up in the wrong place, and I think it's because the word "Unknown" is in the value of the field getting skipped. Is there a workaround for this?
Workaround for what, specifically? You haven't described what exactly goes wrong. "wrong place" isn't meaningful without describing the actual output, and the desired output. All you've essentially said is you get a result you don't like.

You will need to provide the contents of all the relevant fields for the file that's causing the undesired behavior, and also a precise statement of what you actually want the result to be for that file.  Then we'll be able to see what's wrong with your code.  Please be as descriptive and precise as possible.

If your problem is your code doesn't properly process Liam Neeson's 2011 movie "Unknown" then that's what I said above. It's just bad programming: don't use the word unknown for a marker in a place where you might encounter it normally. Use a string you will never encounter as part of a title. Like @UNKNOWN@ or !INVALID! or something like that.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Using if... isequal... unknown when "Unknown" is in the path?
« Reply #2 on: August 15, 2020, 12:15:58 am »

I haven't looked at the detail, but generally test for an empty field, and not a field containing "unknown", which is placed in a path when a field used for RM&CF uses an empty field.

But that could be completely wrong, because I didn't read everything.
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

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Using if... isequal... unknown when "Unknown" is in the path?
« Reply #3 on: August 15, 2020, 01:22:54 am »

That would be the right advice in a normal situation, but he's apparently not in a normal situation.  He says his expression works always works except for this one file, so for some reason he has some "unknown" strings written to some of those fields.  I'm guessing he has some other utility that is entering those values, or maybe they are downloads, and so he's seeing those "unknown" values in the fields and that's why he wrote his expression that way.

Dasfoo, I presume you know that if MC doesn't have a value to put in a field, it leaves the field empty, and you can test for that with something like:
If(!IsEmpty([Movie Title]),\[Movie Title])
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Using if... isequal... unknown when "Unknown" is in the path?
« Reply #4 on: August 15, 2020, 04:14:33 am »

Remembering that, when using the RNM&C tool, even empty fields are not empty unless you specifically tell it to use the raw field data by adding ",0" inside the field. I'm not sure if that's relevant here... feels like it might be though.

If(IsEmpty([Movie Title,0]),\[Movie Title])

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 it's concerned, the field is not empty.

You can use the same method to turn this off, ie...
Quote
[Media Type]\[Media Sub Type]if(isempty([series,0]),,[series])\if(isempty([album,0]),[name],[album])
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.

-marko

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: Using if... isequal... unknown when "Unknown" is in the path?
« Reply #5 on: August 15, 2020, 07:32:18 am »

Logged
Pages: [1]   Go Up