IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Multi-value field w/ duplicated value, any way to show it only 1 time?, [was “Multivalue fields with same value question”/TOS #6]
silkcut
post Feb 2 2013, 22:47
Post #1





Group: Members
Posts: 48
Joined: 8-October 07
Member No.: 47695



Hello. Does anyone know how to compare values in multivalue fields and if they are the same then just display the value once?

e.g. say my PUBLISHER tag has Sire;Sire;Sire (It's stupid I know but I use Discogs Tagger and Discogs has multiple values for record labels even if it is the same record label.) , how can I have foobar2000 test for this and only display Sire?

Right now in my SimPlaylist grouping I have:

CODE
[$crlf()$replace(>>$meta_sep(PUBLISHER,' / ') ,', ',$crlf()>>)]


which inserts a "/" in between the values if they are different. e.g. "Sire / Mute" if PUBLISHER field is "Sire; Mute". But it still shows "Sire / Sire / Sire" when I would like it to just show "Sire".

Thanks!!
Go to the top of the page
+Quote Post
BenB
post Feb 3 2013, 00:36
Post #2





Group: Members
Posts: 729
Joined: 17-April 12
Member No.: 98921



Try this:
CODE
$if($and($greater($meta_num(publisher),1),$strcmp($meta(publisher,1),$meta(publisher,2))),
$meta(publisher,1),
$meta_sep(publisher,' / '))

It checks to see if there are multiple values and the first and second values match. If they do, it returns only the first value. Otherwise it returns all values (including a tag with a single value).

I'll let you figure out how to incorporate it into your existing title formatting. I'd fix the duplicate tags if I were you.

This post has been edited by BenB: Feb 3 2013, 00:36
Go to the top of the page
+Quote Post
BenB
post Feb 3 2013, 03:16
Post #3





Group: Members
Posts: 729
Joined: 17-April 12
Member No.: 98921



Scratch that title formatting. It should be:
CODE
$if($and($greater($meta_num(publisher),1),$strcmp($meta(publisher,0),$meta(publisher,1))),
$meta(publisher,0),
$meta_sep(publisher,' / '))

Ugh. I can't believe I forgot the enumeration begins with 0.
Go to the top of the page
+Quote Post
silkcut
post Feb 8 2013, 16:29
Post #4





Group: Members
Posts: 48
Joined: 8-October 07
Member No.: 47695



Thanks. This will help.

Yes I think I will fix the tags instead. Is there a command that will remove duplicate values? i.e. %PUBLISHER% "Sire;Sire;Sire" ----> "Sire"
Go to the top of the page
+Quote Post
BenB
post Feb 8 2013, 18:00
Post #5





Group: Members
Posts: 729
Joined: 17-April 12
Member No.: 98921



No, there is nothing I'm aware of that will remove duplicates for you.

The script I gave you is based on the assumption that if the 1st and 2nd values match (a=b), then the 1st and 3rd values also match (a=c), thus all three values match (a=b=c). If this is always true then the script can be modified to this:
CODE
$if($and($greater($meta_num(publisher),1),$strcmp($meta(publisher,0),$meta(publisher,1))),$meta(publisher,0),$meta(publisher,0)[; $meta(publisher,1)[; $meta(publisher,2)]])

for use with "Format from other fields" in the Properties dialog. It also assumes that the tag will never have more than 3 values.

On the other hand, if there are other scenarios, such as:
CODE
a=b,a≠c
a≠b,a=c
a≠b,a≠c,b=c

then the script will have to be modified to take them into account to remove duplicates.

This post has been edited by BenB: Feb 8 2013, 18:04
Go to the top of the page
+Quote Post
silkcut
post Feb 10 2013, 01:02
Post #6





Group: Members
Posts: 48
Joined: 8-October 07
Member No.: 47695



Great. Thanks so much for your help!
Go to the top of the page
+Quote Post
BenB
post Feb 11 2013, 00:07
Post #7





Group: Members
Posts: 729
Joined: 17-April 12
Member No.: 98921



You're welcome. I'm glad it worked for you.

I went ahead and wrote a script for use with "Format from other fields" that takes the scenarios into account I mentioned in my last post. Another difference is that it takes tags having more than 3 values into account and leaves them unchanged. I wasn't going to post it unless you couldn't use that last script I gave, but I'll post it anyway. I could probably tidy it up a bit using variable operations but meh.

CODE
$ifequal($meta_num(publisher),3,$if($and($not($strcmp($meta(publisher,0),$meta(publisher,1))),$not($strcmp($meta(publisher,0),$meta(publisher,2))),$not($strcmp($meta(publisher,1),$meta(publisher,2)))),$meta_sep(publisher,'; '),$if($not($strcmp($meta(publisher,0),$meta(publisher,1))),$meta(publisher,0); $meta(publisher,1),$if($not($strcmp($meta(publisher,0),$meta(publisher,2))),$meta(publisher,0); $meta(publisher,2),$meta(publisher,0)))),$ifequal($meta_num(publisher),2,$if($not($strcmp($meta(publisher,0),$meta(publisher,1))),$meta(publisher,0); $meta(publisher,1),$meta(publisher,0)),[$meta_sep(publisher,'; ')]))


This post has been edited by BenB: Feb 11 2013, 00:08
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd August 2014 - 19:56