Add "genre" tag

Hello,

I found this script which matches my needs.
I would like to add the “genre” tag parenting all this.
Could you help?
Regards

$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
        [Various Artists],
	$left($if2(%albumartistsort%,%artistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^\)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, \(Disc %discnumber%\),),)
/
$num(%tracknumber%,2). $left(%title%,120),[:?"_]+,),  , )

The basic idea is that you just have to add the %genre% tag where you want it to have, so something like this should do:

%genre%/$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
[Various Artists],
$left($if2(%albumartistsort%,%artistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, (Disc %discnumber%),),)
/
$num(%tracknumber%,2). $left(%title%,120),[:?"_]+,), , )

But maybe you also want to have some different folder if there is no genre set. In this case instead of just using %genre% use e.g. $if(%genre%,%genre%,No Genre). Replace “No Genre” with whatever you want to name the folder.

One caveat with using genre is that you often will have multiple genres, and %genre% will just show them all. So you will get a folder named e.g. “rock; folk rock”. This depends a bit on where you get the genres from. If you use the built-in genre support you could configure it to use only a single genre in Options > Metadata > Genres.

Or you again use scripting to use only the fist track. Instead of %genre% then use $rreplace( %genre%,;.*,). Combined with the “No Genre” change above this would give you a script like:

$if(%genre%,$rreplace( %genre%,;.*,),No Genre)/$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
[Various Artists],
$left($if2(%albumartistsort%,%artistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, (Disc %discnumber%),),)
/
$num(%tracknumber%,2). $left(%title%,120),[:?"_]+,), , )
1 Like