Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Multi-value field w/ duplicated value, any way to show it only 1 time? (Read 1630 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Multi-value field w/ duplicated value, any way to show it only 1 time?

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: [Select]
[$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!!

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #1
Try this:
Code: [Select]
$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.

 

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #2
Scratch that title formatting. It should be:
Code: [Select]
$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.

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #3
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"

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #4
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: [Select]
$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: [Select]
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.

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #5
Great.  Thanks so much for your help!

Multi-value field w/ duplicated value, any way to show it only 1 time?

Reply #6
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: [Select]
$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,'; ')]))