INTERACT FORUM

Please login or register.

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

Author Topic: AND in expressions ?  (Read 1008 times)

zxsix

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1753
AND in expressions ?
« on: December 26, 2008, 11:26:37 am »

Trying to set up an expression for rename files utility.
I have 3 scenarios I need to address:
1) media type is audio put them in the mp3 folder.
2) media type is image put them in the photos folder.
UNLESS
3) filename is folder.jpg put them in the mp3 folder.

I have no trouble doing the expression for items 1 and 2.  It works properly.
If(IsEqual([Media Type], Audio),mp3\[Genre]\[Artist]\[Album]\,)If(IsEqual([Media Type], Image),Photos\[Genre]\[Album]\,)

The problem arises when dealing with the exception item 3.

Here's what I'm trying, just adding an additional if statement:
If(IsEqual([Media Type], Audio),mp3\[Genre]\[Artist]\[Album]\,)If(IsEqual([Media Type], Image),Photos\[Genre]\[Album]\,)If(IsEqual([Filename (name)], folder.jpg,1),mp3\[Genre]\[Artist]\[Album]\,)

It ends up tacking on additional unwanted folders.  It's applying BOTH of the if statements that are true.  If it would ignore the first one and only use the last one that was true, it would work.  But  it results in this:
\Photos\Genre\Album\mp3\Genre\Artist\Album\folder.jpg
You can see in the different colors where it is using BOTH of the rules.
How can I get it so that if the Media Type = Image AND filename = folder.jpg do a certain thing?
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8950
Re: AND in expressions ?
« Reply #1 on: December 26, 2008, 03:23:10 pm »

What you have there are three completely seperate expressions.
It works for audio files as only the first expression will ever be valid, but, as you have seen, both image expressions are valid for 'folder.jpg' files.

What you need to do is nest your expressions so that you ask "is it an image?" if it is, is it called folder.jpg? if it is, do this, otherwise, do this instead.

That's what this expression does:
If(IsEqual([Media Type], Audio),mp3\[Genre]\[Artist]\[Album]\,If(IsEqual([media type],image,1),If(IsEqual([Filename (name)],folder.jpg,1),mp3\[Genre]\[Artist]\[Album]\,Photos\[Genre]\[Album]\),))

This expression makes the assumption that if the file is not audio, and not called folder.jpg, then it must be a photo:
If(IsEqual([Media Type], Audio),mp3\[Genre]\[Artist]\[Album]\,If(IsEqual([Filename (name)],folder.jpg,1),mp3\[Genre]\[Artist]\[Album]\,Photos\[Genre]\[Album]\))
Both expressions should return the same results.

There are some related ramblings on the wiki, though I'm not sure how clear they are, you might find them useful...
Database Expressions - AND OR And XOR

-marko.

zxsix

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1753
Re: AND in expressions ?
« Reply #2 on: December 26, 2008, 03:59:36 pm »

Works perfectly, thanks!   :D
Logged
Pages: [1]   Go Up