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: I want to specify a user-defined char as splitter of multi-value field (Read 3170 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

I want to specify a user-defined char as splitter of multi-value field

I know this is a repeated topic, but i have not found the exact solution i want after surfing a dozen threads, hence posting.

In Multi-value tag fields like Genre and Artist, I want Foobar to recognize a use-defined character as the splitter. I know foobar can write multiple genre fields (by mass tagger or action), but that makes only the first genre visible when i see in windows explorer folder view. Is it possible to make foobar only read the tag as a string "A;B" and take as input the user-defined splitter ;, thus recognize both A and B as two different genres in Library view?? This behavior is available in mediamonkey, which has the option to both write multi-value tags and no-write-only-read-and-recognize the multi-value tags. I think some formatting (kind of $if,$trim, etc) could do the job in foobar as well. Plz help.

I want to specify a user-defined char as splitter of multi-value field

Reply #1
Sorry not really having an answer but at least basics:
1. To write non-multi-value tags deleting all items in Preferences>Advanced>Display>Properties>Multivalue Fields should help

2. To read ;-separated single values as multivalues, did you try experimenting with $meta* functions? This is the only way I can think about; not sure if that will work. There are also hackarounds like having masstager doing duplicates of all your fields - and basic like GENRE, ARTIST etc. will be single value and copies - GENRE_MULTI, ARTIST_MULTI shall contain splitted value which foobar and other capable players will use. Not really sexy but at least might be working.


I want to specify a user-defined char as splitter of multi-value field

Reply #2
To read ;-separated single values as multivalues, did you try experimenting with $meta* functions? This is the only way I can think about; not sure if that will work.



The $meta function, as the definition says in the attached image, separates existing multiple values of a tag. My case is single value tag, to be parsed into two parts. So need scripting in foobar syntax, which i can't write myself (though i can understand an already written code). Hope some foobar formatting expert could find some time for this Parsing job.

I want to specify a user-defined char as splitter of multi-value field

Reply #3
The library viewer facets has following feature for creating columns:
Quote
Multiple patterns

Multiple patterns can be combined with | to display values from different fields in the same column. For example, %<artist>%|%<composer>% lists both artists and composers, which might be useful to create a list of persons regardless of their actual role.


So i thought that this could work: $replace(%genre%,;,|)
But it doesn't! On the other side an expression like %genre%|<put any text string here> will work. Maybe a request for the facets component?

I want to specify a user-defined char as splitter of multi-value field

Reply #4
Multiple patterns can be combined with | to display values from different fields in the same column. For example, %<artist>%|%<composer>% lists both artists and composers, which might be useful to create a list of persons regardless of their actual role.



I think i got it. I used the above trick and the syntax to 'Find first occurence of character X in %tag%, and return everything in front of or after X'. This is my code in preferences->medialibrary->facets->column genre:

$puts(char,;)$puts(tag,%genre%)$puts(spacer,$strchr($get(tag),$get(char)))$trim($left($get(tag),$sub($get(spacer),1)))|$puts(char,;)$puts(tag,%genre%)$puts(spacer,$strchr($get(tag),$get(char)))$trim($right($get(tag),$sub($len($get(tag)),$get(spacer))))

I am so so so happy...for having written a code :D  and having removed my biggest roadblock to shifting to foobar (the other roadblock being to make foobar recognize my 'rating mm' tag).

Thank you guys for the guidance. :)

I want to specify a user-defined char as splitter of multi-value field

Reply #5
I still do wonder why my simple string leads to a blank pane in facets; in album list this little "trick" works (here | means creating a tree hierarchy)

rkghadai, your code seems to work only if there aren't more than two parts of the value.

(Edit: made a note in facets thread)

I want to specify a user-defined char as splitter of multi-value field

Reply #6
ya it wont work for more than two values. But 'Return everything between two characters' gives me hope that it would be possible write a code for more-than-two values.


I want to specify a user-defined char as splitter of multi-value field

Reply #7
Cool string rkghadai  I have many files with genres split just by colon or slash, I will try that. Good to hear about posting facets issue further too.

 

I want to specify a user-defined char as splitter of multi-value field

Reply #8
Still looking for a flexible code, not restricted to only two values in a tag. Probably for-loop or recursive function is required