INTERACT FORUM

Please login or register.

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

Author Topic: Help with an Expression please  (Read 1117 times)

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Help with an Expression please
« on: May 15, 2020, 12:31:40 am »

I have a field called "Version" which I want to add onto the end of a track name if it has a value.

I tried
[Track #] [Name]ifelse(!isempty([Version]), [Version])

Which works ok if there is a value in Version, but for an empty Version that just gives "01 TracknameUnknown Version.flac" onto the end of the file name.

I copied that last part from the Wiki on IsEmpty and changed disc # to Version. This is what I copied:
ifelse(!isempty([disc #]), [disc #])

    Outputs the value of the disc # field when it is not empty.

Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #1 on: May 15, 2020, 01:48:03 am »

What is the type of field [Version]?
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #2 on: May 15, 2020, 01:50:34 am »

String, one per album, Standard edit.
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #3 on: May 15, 2020, 01:51:29 am »

I haven't been able to find an explanation of what the ! is for either.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10730
Re: Help with an Expression please
« Reply #4 on: May 15, 2020, 01:59:22 am »

I just tried doing the same and had no troubles. Did you put anything special into the Version field? Something in Acceptable Values in the field definition?
Logged
~ nevcairiel
~ Author of LAV Filters

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #5 on: May 15, 2020, 02:04:38 am »

I just tried doing the same and had no troubles. Did you put anything special into the Version field? Something in Acceptable Values in the field definition?
Well in the files that have something in the Version, there is an Em space (which can't be typed - has to be copy & pasted in)

Em space is here between the  quote marks ' '. But surely it can't be that because when that is present it works just fine. It's only when the Version is empty that I get Unknown Version.

So if there is a version number, it looks like this ' v2'
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #6 on: May 15, 2020, 02:13:36 am »

I haven't been able to find an explanation of what the ! is for either.
! means NOT so !IsEmpty means is not empty i.e. has value
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #7 on: May 15, 2020, 02:17:12 am »

Are you using this in Rename, Move and Copy tool? There are a little different rules there with isEmpty
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #8 on: May 15, 2020, 02:18:31 am »

Are you using this in Rename, Move and Copy tool?
Yes.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #9 on: May 15, 2020, 02:21:41 am »

Ok, that's the problem. There are a little different rules for IsEmpty in RMC tool so you can't do it like that in there...

There might be some smarter way to do this but I think that something like this could work:

Code: [Select]
If(!IsEqual([Version],Unknown Version),/ [Version],)
So if Version is something else than "Unknown Version" (which means empty inside RMC tool) then display it otherwise display nothing from Version field

whole thing:
Code: [Select]
[Track #] [Name]If(!IsEqual([Version],Unknown Version),/ [Version],)"/ " is there to make one whitespace and can be removed if your version field already contains some separation

E: edited some parts
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #10 on: May 15, 2020, 02:38:48 am »

Cracker! That works very nicely lepa, and thank you for your help. For the first composer I had employed a workaround - sort them by version and don't apply the rule to the known blanks, but much neater to do it all in one hit, and I have several composers to go....
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #11 on: May 15, 2020, 02:42:13 am »

Glad it worked and thanks for reporting back  :)
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #12 on: May 15, 2020, 02:55:50 am »

So I have a related question now  :) You were saying that in Rename/Move it works differently but where else can those expressions be used? I had a look through Clean File Properties, and there is no scope that I can see for Expressions there.

The reason I ask is because I would like to add the values of a couple of fields to the track name, but can't see how to automate that.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #13 on: May 15, 2020, 03:01:57 am »

Short answer: Expressions can be used (almost) everywhere where you can enter fields. You can make new columns (dynamic for some just one view or actual new database field in the options) for views which are expressions, change your tooltilps and thumbnail capition with expresssions and probably many places I didn't remember
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #14 on: May 15, 2020, 03:06:03 am »

Ok, yes I have done some of that, and I have some fields that are calculated, but is it possible to do a batch of automated names? (in a similar way to what I have just done with filename)?
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #15 on: May 15, 2020, 03:11:29 am »

batch of automated names? (in a similar way to what I have just done with filename)?
Sorry, I don't get what you mean...

Like this?
You could make new field e.g. "Track Name Extended" which would be calculated field which gets its data from e.g. [Name] [Field1] [Field2] etc and of course you can use there those expression functions also.
Code: [Select]
[Name]If(!IsEmpty([Field1]),/ [Field1],)If(!IsEmpty([Field2]),<font color="444444">/ [Field2]<//font>,)
Then use this [Track Name Extended] as a column instead or [Name] or however you like
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #16 on: May 15, 2020, 03:14:43 am »

 :D Yes, I thought that might be the answer - I meant in the actual track name, but I assume (from your reply) that it is sacrosanct, and therefore can't be formulated.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #17 on: May 15, 2020, 03:24:09 am »

Well I guess you could make (not sure) [Name] field calculated but then how would you edit the Name?

Instead you can make expression column in your view by pressing right mouse over the columns and "Add Expression field", name it as "Name" and enter your expression rule in there which will add all the extras to your "Name" expression column
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #18 on: May 15, 2020, 03:28:54 am »

Yes, I see.

I meant so that the data was put in the name field, and could then be edited (no residual calculation) - in the same way that I have just created the filenames by a calculation, but they are now just data, which can be renamed if necessary.

Anyway, it isn't too important to do the name field. Thanks very much for your help with this - much appreciated.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #19 on: May 15, 2020, 03:36:53 am »

Ah, do you mean like this?

If you select items (songs) then edit Name field by pressing F2. You can then put your expression there also and ALL selected songs will get data your expression is commanding. To do that you need to put "=" character before the expression

SO:
Code: [Select]
=[Name]would just copy the sane content as there was
Code: [Select]
=[Name] [Field1] [Field2]would replace all selected names with original contents plus that new field contents

Be careful with that select only one file at first and ctrl+z is UNDO ;D
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #20 on: May 15, 2020, 03:53:02 am »

Oooooo, that's very close to what I'm after. I'll just do some more testing.
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #21 on: May 15, 2020, 04:01:09 am »

Yes, that's very nearly it. It would be perfect if I didn't have to eliminate some stuff at the same time. I promise this is the last question (gotta cook dinner).

In a fit of creativity the other day, I decided to put
[K.43]  Allegro
as the file name, and now I want to get rid of the '[K.43]  '. Is there a way of either truncating 8 characters off the left, or using a wild card to get rid off anything between [ and ] including the [ ]? There are two spaces after the ], but I know I can clean them off easily.

So where I might have
[K.19]  Andante
I now want to put
I. Andante

The "I" movement number can be supplied from the Movement field, so the following would work if I was first able to eliminate [K.19]
=[Movement]. [Name]
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #22 on: May 15, 2020, 04:09:08 am »

https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListItem
ListItem(/[K.43/]  Allegro,1,/]/  )
Will give you just Allegro as it makes list of the whole string and uses "]  " as a separator and displays just second item in the list (index = 1)

So
=[Movement]. ListItem([Name],1,/]/  )
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #23 on: May 15, 2020, 04:10:56 am »

Fabulous, thanks very much lepa!
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #24 on: May 15, 2020, 04:34:40 am »

Hmmmm, having a little trouble getting that to work. If I select 3 tracks, F2, and then
=[Movement]. ListItem([Name],1,/]/  )

I just get names of
I.
II.
III.

instead of
I. Allegro
II. Andante
III. Presto

and there is sometimes a double space after the ], but also it can be an En space. Sorry if that complicates things.

They were originally
[K.19]  Allegro
[K.19]  Andante
[K.19]  Presto
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #25 on: May 15, 2020, 04:40:53 am »

WAIT! I got it right! I didn't see you had a double space in your expression, so when I replaced that with a En space it works....

hang on a sec....

YES! You have saved me a helluva lot of manual editing! Thanks again!
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Help with an Expression please
« Reply #26 on: May 15, 2020, 05:06:44 am »

Nice adaptation :)
Other way to solve this would have been using Mid function IF the length of the prefix to be trimmed out is always same
https://wiki.jriver.com/index.php/String_Manipulation_Functions#Mid
Logged

FenceFurniture

  • Galactic Citizen
  • ****
  • Posts: 420
Re: Help with an Expression please
« Reply #27 on: May 15, 2020, 05:18:24 am »

Crikey - I've finished modifying 421 files in much less time than I spent asking questions!

I am constantly amazed at the power of JRiver. Even simple little intuitive things like it knows which field you want to edit (F2) because that was the field you clicked on.
Logged
Pages: [1]   Go Up