INTERACT FORUM

Please login or register.

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

Author Topic: Artist List from String and string manipulation?  (Read 5401 times)

BadMax

  • Recent member
  • *
  • Posts: 26
Artist List from String and string manipulation?
« on: July 06, 2016, 07:44:16 pm »

The software i use makes a tag "H2_MULTIPLE_ARTISTS" and i made a custom field with that name.

The output is (string):
|Donald & The Others|and|Donald Duck|&|Gus Goose|feat|Daisy|

I want my artist view to list:
Donald & The Others
Donald Duck
Gus Goose
Daisy

but i can't figure out the expression.
I need to remove the pipe (|) and also need to tell the expression that "and", "feat" and "&" need to be removed.
But they only need to be removed if they are standalone between pipes.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Artist List from String and string manipulation?
« Reply #1 on: July 06, 2016, 07:56:26 pm »

Something like:

Code: [Select]
replace([H2_MULTIPLE_ARTISTS],|and,)
Then add on replace expressions for the other two cases and your list should be clean then.  Then just replace the pipes with semicolons and you should have a JRiver formatted list.

Note that the key here is to prefix your "bad terms" with a pipe.  So "|&", "|feat", etc.

Brian.
Logged

BadMax

  • Recent member
  • *
  • Posts: 26
Re: Artist List from String and string manipulation?
« Reply #2 on: July 06, 2016, 09:52:05 pm »

Sorry but that does not work:
Code: [Select]
replace([H2_MULTIPLE_ARTISTS],|and,)replace([H2_MULTIPLE_ARTISTS],|feat,)replace([H2_MULTIPLE_ARTISTS],|&,)replace([H2_MULTIPLE_ARTISTS],|,) :(
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: Artist List from String and string manipulation?
« Reply #3 on: July 07, 2016, 12:49:55 am »

I'm pretty sure you have to do these one at a time, unless there's a fancy regex way to do it one go... Brian?
(I don't mean one file at a time, I mean one 'replace' pass at a time)

Also, when doing these, you need to have a leading 'equals' sign. This tells MC that you want it to perform the specified 'replace' action on the field, rather than make it literally "replace([H2_MULTIPLE_ARTISTS],|and,)"

Make sense so far?

So, you make your selection of files, then open that [H2_MULTIPLE_ARTISTS] field for editing...
It should have "Varies" hilighted...

In there, enter: =replace([H2_MULTIPLE_ARTISTS],|and,)
and press enter.
Did that work?
If not, press ctrl+z to undo whatever just happened, and let us know.
If yes, then we're good to go...
Do the same as above, but change the expression...
=replace([H2_MULTIPLE_ARTISTS],|&,)

and then,

=replace([H2_MULTIPLE_ARTISTS],|feat,)

Edit:
ferday caught the leading and trailing pipes so I'll put this here in case you miss it down there at the bottom :)
ferday, I missed the beginning and end ones completely...

We can take care of those too. In fact, we should take care of those first, before they get made into semi colons...

=RemoveCharacters([H2_MULTIPLE_ARTISTS],|,1)

and

=RemoveCharacters([H2_MULTIPLE_ARTISTS],|,2)

mode one removes the pipe from the beginning, mode two removes it from the end.

Now that the field is cleaned up, all that's left to do is replace those pipes with semi colons...
=replace([H2_MULTIPLE_ARTISTS],|,;)

and that should be you all sorted out.

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Artist List from String and string manipulation?
« Reply #4 on: July 07, 2016, 12:52:03 am »

Afaik (no testing) I think you can nest

Replace(replace(replace(...

I would personally do it Markos way to deal with outliers easier, but the beginning and end pipes are going to be a troublemaker
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: Artist List from String and string manipulation?
« Reply #5 on: July 07, 2016, 12:59:37 am »

Just a thought...

I think that you also have the option to just go directly to "replace pipes"...

So if you ran the last one... =replace([H2_MULTIPLE_ARTISTS],|,;)

When you look at a [H2_MULTIPLE_ARTISTS] in a pane in MC, you'll have "&", "and" and "feat" listed there.
Click on "&" in the pane, and all then select all of the files listed for it.
You should now see a little box beside "&" with a tick in it.
Click on that tick, say yes when prompted about pane tagging, and see the tick disappear.
You just removed "&" from the H2_MULTIPLE_ARTISTS field.

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: Artist List from String and string manipulation?
« Reply #6 on: July 07, 2016, 01:03:06 am »

ferday, I missed the beginning and end ones completely...

We can take care of those too. In fact, we should take care of those first, before they get made into semi colons...

=RemoveCharacters([H2_MULTIPLE_ARTISTS],|,1)

and

=RemoveCharacters([H2_MULTIPLE_ARTISTS],|,2)

mode one removes the pipe from the beginning, mode two removes it from the end.

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Artist List from String and string manipulation?
« Reply #7 on: July 07, 2016, 01:07:42 am »

Great tricks mate!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: Artist List from String and string manipulation?
« Reply #8 on: July 07, 2016, 01:18:13 am »

One last little thing...

I just tested this because I wondered if MC might treat the pipe and the ampersand as 'special' characters...
It worked a treat.


but, and this is kind of necessary, only after I had gone back into the field manager and changed "Test Field" from a "Data Type: String" to "Data Type: List (semicolon delimited)"

Now... I think we've covered everything :D

-marko

BadMax

  • Recent member
  • *
  • Posts: 26
Re: Artist List from String and string manipulation?
« Reply #9 on: July 07, 2016, 08:15:57 am »

Sorry as beginner i don't get the "So, you make your selection of files, then open that [H2_MULTIPLE_ARTISTS] field for editing..." part.

Open where? :(

The way i was trying the rule was in "Customize View" where i have category "Artist" and there in "Set rules for file display".
Also i made an  "Expression Column" where i was testing it.

These are the places where i think i need it.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Artist List from String and string manipulation?
« Reply #10 on: July 07, 2016, 08:26:47 am »

Expression columns are definitely the way to test these things.  That's what I just did to develop a new expression.  Because I felt like creating an all-in-one expression for this.  This expression should do everything in one shot:

Code: [Select]
=replace(replace(replace(replace(removecharacters(removecharacters([H2_MULTIPLE_ARTISTS],|,1),|,2),|and,),|&,),|feat,),|,;)
I tested it with your test case and it worked as expected.  I even cut and pasted it into the [Actors] field (since it's a list type field) and it populated individual actors as it should (gus goose, Daisy, etc).

Brian.
Logged

BadMax

  • Recent member
  • *
  • Posts: 26
Re: Artist List from String and string manipulation?
« Reply #11 on: July 07, 2016, 08:58:13 am »

Thanks that works.
But i realized now one little other problem.

If i have only one Artist tagged in my tagging software then the H2_MULTIPLE_ARTISTS field is empty >:(
That means if i have something from "Donald Duck" he is only in the "artist" field.

If i have "Donald Duck & Junior Woodchucks Orchestra":

Artist field: Donald Duck & Junior Woodchucks Orchestra
H2_MULTIPLE_ARTISTS field: |Donald Duck|&|Junior Woodchucks Orchestra|

Edit
This works:
Code: [Select]
If(isempty([H2_MULTIPLE_ARTISTS]), [Artist], replace(replace(replace(replace(removecharacters(removecharacters([H2_MULTIPLE_ARTISTS],|,1),|,2),|and,),|&,),|feat,),|,;) )
But what is the "=" in front of the other code for?

Edit again:
It works in the expression column but not customize view :'(
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Artist List from String and string manipulation?
« Reply #12 on: July 07, 2016, 10:02:30 am »

What do you mean customize view?  How are you trying to use this?

Normally with an operation like this, you'd use it in an expression column first to see if it's working the way you want it

Then you'd go into the actual field itself, and type it in there, which will clean all the tags
Logged

BadMax

  • Recent member
  • *
  • Posts: 26
Re: Artist List from String and string manipulation?
« Reply #13 on: July 07, 2016, 10:29:45 am »

Under "Audio" i made a "Library View" called "Artists"...
There i click "Customized View"...
There i have in Categories "Artist"...
In settings there is "... Set rules for file display..."
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Artist List from String and string manipulation?
« Reply #14 on: July 07, 2016, 11:13:45 am »

Those rules are for displaying based on criteria.  You can use expressions there but it would be difficult to sort on a replace type expression

How are you trying to sort everything?

You really want to "clean" the tags first and then sort on them
Logged

BadMax

  • Recent member
  • *
  • Posts: 26
Re: Artist List from String and string manipulation?
« Reply #15 on: July 07, 2016, 02:10:31 pm »

I want my artist view to list al the artists/bands/orchestras:
Donald & The Others
Donald Duck
Gus Goose
Daisy
Junior Woodchucks Orchestra
Logged
Pages: [1]   Go Up