Sort by Genre

After spending months sorting 30 years of music from many sources I’m almost finished what I want to accomplish but I cannot find a file naming script to sort my music by genre and I’m struggling trying to figure it out. Is it even possible for MBP to sort by genre? I have 2 folders for my music at present:

  1. Alphabetical - FLAC
  2. Alphabetical - MP3
    and I’d like to have 2 more:
  3. Genre - FLAC
  4. Genre - MP3

Here is my current script:

$if($eq($left($if2(%albumartist%,%artist%),4),The ),
$left($if2(%albumartist%,%artist%),1)) - Music/
$if2(%albumartist%,%artist%)/%album% $upper([%_extension%]) [$if(%date%,$if(%album%,)$left(%date%,4)])/
%artist% - %title%

It gives me this:
Music Folder/A - Music/AC_DC/Back in Black [FLAC] [2003]/AC_DC - Back in Black.flac

Which is perfect so far. I’d like to achieve this:
Music Folder/‘Genre’/A - Music/AC_DC/Back in Black [FLAC]…

My music already has genre tags. So I’d like MBP to sort using the genre tag but how do I do that and how do I define what genres I want?
I’ve come across this but I don’t know if this is what I’m looking for:

$noop(★ Sort orderTypeForRoot                      ★)
$noop(★ ~/Music/ Genre/A/Artist/AlbumTitle/ ★)
$noop(★  1: Category []   ★)
$noop(★ ~/Music/A/Artist/AlbumTitle/★)
$noop(★  2: Artist first letter     ★)

Thanks in advance.

1 Like

To get the genre you can use the variable %genre%. This could be a list of genres. To only get the first one use $slice(%genre%,0,1).

Maybe you also need to handle the case that there is no genre? You could add the following code snippet to your script to add a genre folder or “no genre” if there is none:

$if2($slice(%genre%,0,1),no genre)/

Thank you very much. I’ll work on it some more.

1 Like

Your script works perfectly. The only problem is that the plugin gives songs from a band like AC/DC 3 different genres: Rock, Classic Rock, and Hard Rock lol. Ugh. Forcing 1 genre only doesn’t help because it still gives individual songs their own different genre. I might have to do this manually which I’d hoped to avoid. I can see why people don’t recommend sorting by genre.
Thanks again.