INTERACT FORUM

Please login or register.

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

Author Topic: if() expressions with multiple test conditions - Help!  (Read 1461 times)

exodus1977

  • Recent member
  • *
  • Posts: 25
if() expressions with multiple test conditions - Help!
« on: September 15, 2010, 08:17:44 pm »

ok... I can't figure this out and need some help.  I'm trying to create an expression to rename files and I want multiple test conditions to be met.  I have two fields I want tested:

[done] I use this field to indicate that I have entered all the tags and the file is ready to be moved
[video type]  This indicates if its TV, Movie, etc.

I'm trying to do something like this:

if(isequal([done],Yes,1) and isequal([video type],Movie,1),Move to new directory,Don't move)

In other words, the file only gets moved to the new directory if [done]=yes and [video type]=Movie.  If either doesn't match, i don't want the file moved. 

Any ideas?  Thanks.

Logged

221bBS

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 703
Re: if() expressions with multiple test conditions - Help!
« Reply #1 on: September 15, 2010, 09:44:41 pm »

Try
Code: [Select]
If(IsEqual([done],Yes,1),If(IsEqual([video type],Movie,1),Move to new directory,Don't move),Don't move)
Logged

zxsix

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1753
Re: if() expressions with multiple test conditions - Help!
« Reply #2 on: September 15, 2010, 09:47:09 pm »

This should do it.  I'm not at my media computer at the moment so I can't test the syntax.
The section where it starts with [Genre] is the path you want the files moved to if both conditions are true.


Code: [Select]
If(IsEqual([video type],Movie,1),If(IsEqual([done],Yes,1),[Genre]\[Album Artist (auto)]\[Album]\),)
ETA: Beat by mere seconds!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: if() expressions with multiple test conditions - Help!
« Reply #3 on: September 15, 2010, 09:47:58 pm »

221bbs gave a good solution.

You can also use Math(...) to do the logical operators & and |.

I did a little test using the album I'm listening to now which worked fine:
If(Math(IsEqual([Artist], Greg Brown, 1) & IsEqual([Name], Smell Of Coffee, 1)), Match, No Match)

I suppose we could also add And(...) and Or(...) functions for ease.  It's never been requested before.  Thoughts?
Logged
Matt Ashland, JRiver Media Center

exodus1977

  • Recent member
  • *
  • Posts: 25
Re: if() expressions with multiple test conditions - Help!
« Reply #4 on: September 15, 2010, 10:04:05 pm »

Thanks for all the help guys.  The Math() function is interesting, as it would be pretty logical and/or commands.
Logged

)p(

  • Citizen of the Universe
  • *****
  • Posts: 579
Re: if() expressions with multiple test conditions - Help!
« Reply #5 on: September 16, 2010, 02:28:09 am »


I suppose we could also add And(...) and Or(...) functions for ease.  It's never been requested before.  Thoughts?

Yes please! Feels much more natural. I am for anything that makes the expression more readable...longer expressions as they are now are pretty hard to read.
Logged

exodus1977

  • Recent member
  • *
  • Posts: 25
Re: if() expressions with multiple test conditions - Help!
« Reply #6 on: September 16, 2010, 08:29:15 am »

221bbs gave a good solution.

You can also use Math(...) to do the logical operators & and |.

I did a little test using the album I'm listening to now which worked fine:
If(Math(IsEqual([Artist], Greg Brown, 1) & IsEqual([Name], Smell Of Coffee, 1)), Match, No Match)

I suppose we could also add And(...) and Or(...) functions for ease.  It's never been requested before.  Thoughts?

Math() is a good tool for me.  And() Or() would be great to.  I almost got the expression correct, but after looking at 221bbs's code (which worked), I clearly got tripped up trying to nest if() within another if().   
Logged

221bBS

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 703
Re: if() expressions with multiple test conditions - Help!
« Reply #7 on: September 16, 2010, 09:17:43 am »

Quote
I clearly got tripped up trying to nest if() within another if().

I had the same problem when I started learning expressions. I've learned that using Notepad++ and breaking down the code helps me read it a lot better. Like the code above would be broken down like this
Quote
If(
   IsEqual([done],Yes,1)
   ,
   If(
      IsEqual([video type],Movie,1)
      ,
      Move to new directory
      ,
      Don't move
      )
   ,
   Don't move
)

Quote
I suppose we could also add And(...) and Or(...) functions for ease.  It's never been requested before.  Thoughts?

This would help me a lot.


Quote
I did a little test using the album I'm listening to now which worked fine:
If(Math(IsEqual([Artist], Greg Brown, 1) & IsEqual([Name], Smell Of Coffee, 1)), Match, No Match)

Haven't started using the Math function because I haven't learned how to use it yet. anyone else want to post some Math codes for me to get an idea of how it's used?
Logged
Pages: [1]   Go Up