Author Topic: Is it possible to sort songs by number of genres they are related to ?  (Read 902 times)

guigui

  • Newbie
  • *
  • Posts: 2
Hello,

I need a little help
Everything is in the title, at least I hope so  :)

I have several songs which have multiple (too much I think) genres in their tags and I would like to find them quickly
Let's say, identify songs which have 3+ genres, to modify them
But I can't figure out how, is there a way ?

Thank you for your answer
Have a good day

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
Hello and welcome to the forum.

You can create a virtual tag with a formula like:            $IsMatch(<Genres>,.*?;.*?;.*)
It will return T whenever a track has 3 or more genres.

Thereafter, it's up to you how you wish to use that virtual tag.

1. You can create an auto playlist with the criteria <VirtualTag#> is T.
2. You can use a custom search <Ctrl>+F with a similar criteria as in #1.
3. You can display the virtual tag in your main panel and then sort by it.
Strength and Honour (2025)

hiccup

  • Hero Member
  • *****
  • Posts: 9119
You can…
Or use this for a virtual tag:

Code
$IsNull(<Genre>,,$Len($RxReplace(<Genres>,".[^;|\/]*","x")))
Last Edit: August 20, 2023, 02:14:26 PM by hiccup


hiccup

  • Hero Member
  • *****
  • Posts: 9119
Wow, works for me, thank you both!
Great.

P.S.
I updated the formula two posts back, It had a typo and an omission.
Last Edit: August 20, 2023, 02:15:59 PM by hiccup

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
Glad to hear it.

Code
$Len($RxReplace(<Genres>,".[^;]*","x"))
The logic behind this solution is genius, I must say, haha.
Up until now, I hadn't come across a challenge that required me to count the occurrence of a match using regex - but the thought of how to achieve such always lingered in my brain.
I suppose every problem I've ever solved using regex always had an occurrence-type of solution. It seems I just haven't been wired to solve problems that way.

Edit:

Reading what I said above a second time has made it not make much sense - since that's exactly what the solution I offered does as well. What I meant was how yours is much more accurate as it gets the exact number of occurrences as compared to mine which is simply looking for three or more and doesn't know exactly how many of the "more" there are. Anyways...
Last Edit: August 09, 2023, 05:48:39 PM by Mayibongwe
Strength and Honour (2025)

hiccup

  • Hero Member
  • *****
  • Posts: 9119
It seems I just haven't been wired to solve problems that way.
If your fuse has been blown as often as mine in failing to come up with good solutions at first (and second, and third, repeat…) tries, I'm sure you will learn to rewire too ;-)

P.S.
When I get stuck, looking at the overview of all functions for MusicBee formulas often gives me some fresh idea.

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1733
  • Heal The World
When I get stuck, looking at the overview of all functions for MusicBee formulas often gives me some fresh idea.
Funny enough, that's the thread I ran to when I saw your solution.
At first, I couldn't understand the purpose of your $Len in there. So, I'd ran to your cheatsheet thinking there was an explanation I'd missed regarding that function.

I edited my previous post to make it make more sense.
When I looked at this problem (as with all others), I hadn't come from an angle of "first find exactly how many genres there are and bingo" since I've never figured out how I would do that.
So thanks to you, going forward, I now know how to get the exact number of occurrences in a tag. Cheers!
Strength and Honour (2025)