INTERACT FORUM

Please login or register.

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

Author Topic: I am torturing my library again and need a little help.  (Read 2069 times)

666JackTheKnife666

  • World Citizen
  • ***
  • Posts: 150
I am torturing my library again and need a little help.
« on: October 21, 2012, 07:35:00 pm »

Ok recently I have acquired some audio book anthology's and previous to now I had no good way to deal with them so I have set my self to the task of processing them in a logical way.

I use several custom fields for organizing my audio book library they are,
book author (String field)
book title (String Field)
book series (String Field)
book series volume (String Field, I should probably change this to a number field but so far it works)
Display book title (Expression Field, parsing the above fields to create a nice display title)

I am wanting too add two new fields,
Pre book title (a list field) ex:An Anthology;Graphic Audio;Short Story
Post book title(a list field) ex: Abridged;Unabridged

for the past few days i have been mangling my display book title field expression with quite poor results.
the field is either populated with a "1" or "unknown expression error"
here is my current mess of an expression with comments to help explain what I am trying to do.

# is it an audio book ? yes keep going
If(IsEqual([Media Sub Type],Audiobook),

# are the pre book title and post book title fields empty if so ignore them.
if(IsEmpty[Pre Book Title,0]),If(IsEmpty([Post Book Title,0]),
If(IsEmpty([Book Series,0]),[Book Title],[Book Title] - [Book Series] Book [Book Series Volume]),

# this is the case if the post book title field is not empty.
If(IsEmpty([Book Series,0]),[Book Title] [Post Book Title],[Book Title] [Post Book Title] - [Book Series] Book [Book Series Volume]),
# when pre book title is not empty, check and see if post book title is empty if so ignore it.
If(IsEmpty([Post book Title,0]),If(IsEmpty([Book Series,0]),[Pre Book Title] [Book Title],[Pre Book Title] [Book Title] - [Book Series] Book [Book Series Volume]),

# this is the case where both pre and post book title fields have data.
If(IsEmpty([Book Series,0]),[Pre Book Title] [Book Title] [Post Book Title],[Pre Book Title] [Book Title] [Post Book Title] - [Book Series] Book [Book Series Volume])))),)

I am sure there is a much more elegant way of doing this but so far this is my best guess as to how to go about it.
any help is always greatly appreciated.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: I am torturing my library again and need a little help.
« Reply #1 on: October 21, 2012, 07:47:49 pm »

A quick tip - use ListBuild() with the fields to build a longer string.  This will automatically skip the empty fields, so you don't have to test them.  For example, the following will combine all three fields, separated by a space, omitting fields that are empty:

   listbuild(1, / , [Pre book title], [book title], [post book title])
Logged
The opinions I express represent my own folly.

666JackTheKnife666

  • World Citizen
  • ***
  • Posts: 150
Re: I am torturing my library again and need a little help.
« Reply #2 on: October 21, 2012, 09:53:35 pm »

If(IsEqual([Media Sub Type],Audiobook),
If(IsEmpty([Book Series,0]),listbuild(1, / , [Pre book title], [book title], [post book title]),
listbuild(1, / , [Pre book title], [book title], [post book title]) - [Book Series] Book [Book Series Volume])

So this should work ?

Edit:
 I just poped this into my expression and It still gives me "expression error (unknown error)"
the expression wiki for listbuild does not say if it needs wrapped in ( ) but I will mess with it a bit more and see if I can make it work. can you see what I am doing wrong ?
thank you for your help .
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: I am torturing my library again and need a little help.
« Reply #3 on: October 21, 2012, 10:26:29 pm »

It is missing some closing parens.  Maybe you want a simpler:

IfElse(
  IsEqual([Media Sub Type],Audiobook),
    listbuild(1, / ,
     [Pre book title], [Book title], [Post book title]/
     IfElse(!IsEmpty([Book Series,0]), / -/ [Book Series] Book [Book Series Volume])
  )
)

This concatenates the pre-title, title, and post-title, and also appends the book series if not empty along with Book and the volume.
Logged
The opinions I express represent my own folly.

666JackTheKnife666

  • World Citizen
  • ***
  • Posts: 150
Re: I am torturing my library again and need a little help.
« Reply #4 on: October 21, 2012, 11:56:46 pm »

With your help Mr C , I have got it working, I am now getting nice titles like
" Abraham's Boys - From The Anthology By Blood We Live "

Unfortunately I think I am going to have to do this the hard way after all, my expression field [display book title] that all this work has gone into is used in my rename move and copy tool rules and if there is no data in one of the fields it spits out "unknown [field name]" into the result. Using the above result as an example it's
" Abraham's Boys - From The Anthology By Blood We Live Unknown (post book title) "


Any suggestions ?
Logged

666JackTheKnife666

  • World Citizen
  • ***
  • Posts: 150
Re: I am torturing my library again and need a little help.
« Reply #5 on: October 22, 2012, 12:30:13 am »


can the IfElse expression preform multiple tests and if all are true then do an action ?

IfElse(test1 test 2 test 3,do an action) ?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: I am torturing my library again and need a little help.
« Reply #6 on: October 22, 2012, 12:39:27 am »

Unfortunately I think I am going to have to do this the hard way after all, my expression field [display book title] that all this work has gone into is used in my rename move and copy tool rules and if there is no data in one of the fields it spits out "unknown [field name]" into the result. Using the above result as an example it's
" Abraham's Boys - From The Anthology By Blood We Live Unknown (post book title) "

Any suggestions ?

Fields have two output modes: one is a Raw mode, and the other is a Display mode.  The Rename tool uses the Display mode.  To prevent output such as "Unknown", use the Raw mode in the fields:

IfElse(
  IsEqual([Media Sub Type],Audiobook),
    listbuild(1, / ,
     [Pre book title,0], [Book title,0], [Post book title,0]/
     IfElse(!IsEmpty([Book Series,0]), / -/ [Book Series,0] Book [Book Series Volume,0])
  )
)
Logged
The opinions I express represent my own folly.

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: I am torturing my library again and need a little help.
« Reply #7 on: October 22, 2012, 12:42:42 am »

can the IfElse expression preform multiple tests and if all are true then do an action ?

IfElse(test1 test 2 test 3,do an action) ?

Not exactly like that.  What you're asking for is an AND between the tests.  This can be simulated in several ways.  See the AND mode in this article:

   http://wiki.jriver.com/index.php/Database_Expressions_AND_OR_And_XOR
Logged
The opinions I express represent my own folly.

666JackTheKnife666

  • World Citizen
  • ***
  • Posts: 150
Re: I am torturing my library again and need a little help.
« Reply #8 on: October 22, 2012, 01:58:17 am »

The ,0 thing did the trick, darn it I knew that too from some other work I was doing a few week's ago, slipped my mind.
sorry for all the hassle and let me give you a huge thank you!!

Logged
Pages: [1]   Go Up