Script to create an album genre from its various recording genres

F.w.i.w, I have changed my ways since.
E.g. I am no longer using the wikidata genre plugin. (too many bad results)
Also the genre script has been improved a lot over time.

See here for my updated system.

3 Likes

Thanks for the update @hiccup. I copied your whitelist and scripts. Thanks for all your effort!

1 Like

So, this is an end point, right?
I would like to get the same as you’re trying here, a solid genre per album based on tracks genres. Let’s say, take the three or five top genres of the count and stamp it on main Genre. I would be happy even if no priorization involved, just all the genres detected on a row without duplicated entries.
You get it to work aside the scripts on this threat?

( I have a large collection properly tagged by picard over years, but in old versions genres was added as single;line;semicolon;separated. So I need to rewrite the whole stuff with multiple genre-frames. I’m setting up moode audio and a track based genre is a complete nonsense mess for that).

There are some differences. Here are my current scripts in the order they run…

  1. Create Persistent Variable of Aggregated Genres (same as above)
$noop(___Script A: Create Persistent Var of Aggregated Genres___)
$if($and(%genre%,$not(%_processed%)),
  $set(_temp,$replace($replace(%genre%,; ,;),;,; ))
  $set_a(_common_genre,$trim($get_a(_common_genre); %_temp%, ;))
  $unset(_temp)
)
$set(_processed,$add($if2(%_processed%,0),1))
  1. Create MultiVariable from Persistent Variable
$noop(___Script B: Create MultiVar from Persisten Variable___)
$if($and(_common_genre,$not(%_processed2%)),
  $if($eq(%_absolutetracknumber%,1),
    $set_a(_aggregate_genre1,$get_a(_common_genre))
    $setmulti(_temp,$replace($replace(%genre%,; ,;),;,; ))
    $set_a(track1_genre_length,$lenmulti(%_temp%))
    $unset(_temp)
  )
  $setmulti(_aggregate_genre,$get_a(_aggregate_genre1))
  $setmulti(_aggregate_genre,$slice(%_aggregate_genre%,,-$get_a(track1_genre_length)))
  $set(_aggregate_genre_length,$lenmulti(%_aggregate_genre%))
)
$set(_processed2,$add($if2(%_processed2%,0),1))
  1. Count & Save Freq of Recording Genres
$noop(___Script D: Count & Save Freq of Recording Genres___)
$if(%_genre_count_processed%,,
  $foreach($get(_aggregate_genre),
    $set(_genre_key,_Genre '%_loop_value%' count)
    $set(%_genre_key%,$add($if2($get(%_genre_key%),0),1))
    $unset(_genre_key)
  ,; )
)
$set(_genre_count_processed,1)
  1. Generate “album_genre” from genre counts above, then copy it to main genre tag…
$noop(___Create album genre from genre counts___)
$if(%_album_genre_processed%,,
  $foreach($get(_aggregate_genre),
    $if($gte($mul($get(_Genre '%_loop_value%' count),2),%_totalalbumtracks%),
      $if($not(%_album_genre%),$setmulti(_album_genre,%_loop_value%),
      $copymerge(_album_genre,_loop_value))
    )
  )
)
$set(genre,%_album_genre%)
$set(_album_genre_processed,1)
  1. Clean genres similar to @hiccup 's link above…
$setmulti(_genre,$title(%genre%))
$setmulti(_genre,$map(%_genre%,$upper($substr(%_loop_value%,0,1))$substr(%_loop_value%,1,)))
$replacemulti(%_genre%,Aor,AOR)
$replacemulti(%_genre%,Eai,EAI)
$replacemulti(%_genre%,Ebm,EBM)
$replacemulti(%_genre%,Edm,EDM)
$replacemulti(%_genre%,Funk de bh,Funk de BH)
$replacemulti(%_genre%,Idm,IDM)
$replacemulti(%_genre%,Midi music,MIDI music)
$replacemulti(%_genre%,Mpb,MPB)
$replacemulti(%_genre%,Nwobhm,NWoBHM)
$replacemulti(%_genre%,R&b,R&B)
$replacemulti(%_genre%,Uk bass,UK Bass)
$replacemulti(%_genre%,Uk drill,UK Drill)
$replacemulti(%_genre%,Uk funky,UK Funky)
$replacemulti(%_genre%,Uk garage,UK Garage)
$replacemulti(%_genre%,Uk hard house,UK Hard House)
$replacemulti(%_genre%,Uk hardcore,UK Hardcore)
$replacemulti(%_genre%,Uk hip hop,UK Hip Hop)
$replacemulti(%_genre%,Uk jackin',UK Jackin')
$replacemulti(%_genre%,Uk street soul,UK Street Soul)
$replacemulti(%_genre%,Us power metal,US Power Metal)
$replacemulti(%_genre%,Afoxê,Afoxé)
$replacemulti(%_genre%,Afro rock,Afro-rock)
$replacemulti(%_genre%,Afro-zouk,Zouk)
$replacemulti(%_genre%,Alternative country,Alt-country)
$replacemulti(%_genre%,American primitivism,American Primitive Guitar)
$replacemulti(%_genre%,Andean music,Andean Folk Music)
$replacemulti(%_genre%,Andean,Andean Folk Music)
$replacemulti(%_genre%,Appalachian folk,Appalachian Folk Music)
$replacemulti(%_genre%,Appalachian music,Appalachian Folk Music)
$replacemulti(%_genre%,Arabesque rap,Arabesk Rap)
$replacemulti(%_genre%,Avtorskaya pesnya,Bard Song)
$replacemulti(%_genre%,Azonto,Afrobeats)
$replacemulti(%_genre%,Baggy,Madchester)
$replacemulti(%_genre%,Balearic trance,Ibiza Trance)
$replacemulti(%_genre%,Ballroom house,Ballroom)
$replacemulti(%_genre%,Baroque era,Baroque)
$replacemulti(%_genre%,Beatdown,Beatdown Hardcore)
$replacemulti(%_genre%,Beijing opera,Peking Opera)
$replacemulti(%_genre%,Bele,Bélé)
$replacemulti(%_genre%,Bleep,Bleep Techno)
$replacemulti(%_genre%,Brass and military,Brass & Military)
$replacemulti(%_genre%,Breaks,Breakbeat)
$replacemulti(%_genre%,Brit funk,Britfunk)
$replacemulti(%_genre%,Bubblegum,Bubblegum Pop)
$replacemulti(%_genre%,Cabo zouk,Cabo-zouk)
$replacemulti(%_genre%,CCM,Contemporary Christian)
$replacemulti(%_genre%,Chanson française,Chanson)
$replacemulti(%_genre%,Christian black metal,Unblack Metal)
$replacemulti(%_genre%,Christmas,Christmas Music)
$replacemulti(%_genre%,Classical period,Classical Era)
$replacemulti(%_genre%,Club,Club-house)
$replacemulti(%_genre%,Colinde,Colindă)
$replacemulti(%_genre%,Comedy hip hop,Comedy Rap)
$replacemulti(%_genre%,Country and irish,Country & Irish)
$replacemulti(%_genre%,Cretan,Cretan Folk Music)
$replacemulti(%_genre%,Crust,Crust Punk)
$replacemulti(%_genre%,Cuban charanga,Charanga)
$replacemulti(%_genre%,Cubaton,Cubatón)
$replacemulti(%_genre%,Dangak,Dang-ak)
$replacemulti(%_genre%,Dansband,Dansbandsmusik)
$replacemulti(%_genre%,Danzon,Danzón)
$replacemulti(%_genre%,Dark country,Gothic Country)
$replacemulti(%_genre%,Dark wave,Darkwave)
$replacemulti(%_genre%,Darkcore,Darkside)
$replacemulti(%_genre%,Death-doom metal,Death Doom Metal)
$replacemulti(%_genre%,Dimotiko,Dimotika)
$replacemulti(%_genre%,Doina,Doină)
$replacemulti(%_genre%,Donosti sound,Sonido Donosti)
$replacemulti(%_genre%,Drumless hip hop,Drumless)
$replacemulti(%_genre%,Dubwise,Dubwise Drum and Bass)
$replacemulti(%_genre%,Educational,Educational music)
$replacemulti(%_genre%,Electroacoustic improvisation,EAI)
$replacemulti(%_genre%,Electro-funk,Electro)
$replacemulti(%_genre%,Electropunk,Synth Punk)
$replacemulti(%_genre%,Emo pop,Emo-pop)
$replacemulti(%_genre%,Éntekhno,Entechna)
$replacemulti(%_genre%,Estrada,Soviet Estrada)
$replacemulti(%_genre%,Favela funk,Funk Carioca)
$replacemulti(%_genre%,Field recordings,Field Recording)
$replacemulti(%_genre%,Fife and drum,Fife and Drum Corps)
$replacemulti(%_genre%,Forro,Forró)
$replacemulti(%_genre%,Free tekno,Freetekno)
$replacemulti(%_genre%,Full-on,Full-on Psytrance)
$replacemulti(%_genre%,Funaná,Funaná)
$replacemulti(%_genre%,Funk brasileiro,Funk Carioca)
$replacemulti(%_genre%,Gamelan joged bumbung,Gamelan Jegog)
$replacemulti(%_genre%,Gamelan selunding,Gamelan Selonding)
$replacemulti(%_genre%,Género grande,Zarzuela Grande)
$replacemulti(%_genre%,Glam,Glam Rock)
$replacemulti(%_genre%,Glitch hop edm,Glitch Hop [EDM])
$replacemulti(%_genre%,Goth rock,Gothic Rock)
$replacemulti(%_genre%,Gothic,Gothic Rock)
$replacemulti(%_genre%,Grand opéra,Grand Opera)
$replacemulti(%_genre%,Greenlandic music,Inuit)
$replacemulti(%_genre%,Guaracha edm,Guaracha [EDM])
$replacemulti(%_genre%,Guoyue,Minyue)
$replacemulti(%_genre%,Hard nrg,NRG)
$replacemulti(%_genre%,Hardcore [edm],Hardcore Techno)
$replacemulti(%_genre%,Hi-tech,Hi-tech Psytrance)
$replacemulti(%_genre%,Hyangak,Hyang-ak)
$replacemulti(%_genre%,Impressionist,Impressionism)
$replacemulti(%_genre%,Indigenous andean music,Andean Folk Music)
$replacemulti(%_genre%,Indo jazz,Indian Jazz Fusion)
$replacemulti(%_genre%,Irish folk,Irish Folk Music)
$replacemulti(%_genre%,Izvorna,Izvorna Bosanska Muzika)
$replacemulti(%_genre%,Jackin house,Jackin' House)
$replacemulti(%_genre%,Javanese gamelan,Gamelan Jawa)
$replacemulti(%_genre%,Jazz manouche,Gypsy Jazz)
$replacemulti(%_genre%,Jazz rock,Jazz-rock)
$replacemulti(%_genre%,Jeongak,Jeong-ak)
$replacemulti(%_genre%,Jump up,Jump-up)
$replacemulti(%_genre%,Kasékò,Kaseko)
$replacemulti(%_genre%,khmer music,Khmer Folk Music)
$replacemulti(%_genre%,Koplo,Dangdut Koplo)
$replacemulti(%_genre%,Korean court music,Korean Classical)
$replacemulti(%_genre%,Kuda kepang,Kuda Lumping)
$replacemulti(%_genre%,Kumi-daiko,Taiko)
$replacemulti(%_genre%,Laiko,Laika)
$replacemulti(%_genre%,Laïkó,Laika)
$replacemulti(%_genre%,Lao music,Lao Folk Music)
$replacemulti(%_genre%,Lectures,Lecture)
$replacemulti(%_genre%,Liquid funk,Liquid Drum and Bass)
$replacemulti(%_genre%,Lute song,Elizabethan Song)
$replacemulti(%_genre%,Mangue beat,Manguebeat)
$replacemulti(%_genre%,Maskanda,Maskandi)
$replacemulti(%_genre%,Medieval classical music,Medieval)
$replacemulti(%_genre%,Melodic trance,Uplifting Trance)
$replacemulti(%_genre%,Menzuma,Manzuma)
$replacemulti(%_genre%,Mittelalter-metal,Medieval Metal)
$replacemulti(%_genre%,Mo lam,Mor Lam)
$replacemulti(%_genre%,Modern electric blues,Electric Blues)
$replacemulti(%_genre%,Modern hardtek,Hardtek)
$replacemulti(%_genre%,Modern laiko,Modern Laika)
$replacemulti(%_genre%,Molam sing,Mor Lam Sing)
$replacemulti(%_genre%,Molam,Mor Lam)
$replacemulti(%_genre%,Motown,Motown Sound)
$replacemulti(%_genre%,Movie soundtrack,Film Soundtrack)
$replacemulti(%_genre%,Mugham,Azerbaijani Mugham)
$replacemulti(%_genre%,Música criolla,Música Criolla Peruana)
$replacemulti(%_genre%,Narodnozabavna glasba,Narodno Zabavna Glasba)
$replacemulti(%_genre%,Nature sounds,Nature Recordings)
$replacemulti(%_genre%,Néo kyma,Neo Kyma)
$replacemulti(%_genre%,Neoclassical dark wave,Neoclassical Darkwave)
$replacemulti(%_genre%,Neo-trad,Néo-trad)
$replacemulti(%_genre%,Neo-traditionalist country,Neo-traditional Country)
$replacemulti(%_genre%,Nerdcore,Nerdcore Hip Hop)
$replacemulti(%_genre%,New wave of british heavy metal,NWoBHM)
$replacemulti(%_genre%,No melody,No Melody Trap)
$replacemulti(%_genre%,Nu disco,Nu-disco)
$replacemulti(%_genre%,Nueva cancion,Nueva Canción)
$replacemulti(%_genre%,Nuevo flamenco,Flamenco Nuevo)
$replacemulti(%_genre%,Nuevo tango,Tango Nuevo)
$replacemulti(%_genre%,Nyū myūjikku,New Music)
$replacemulti(%_genre%,Occitan,Occitan Folk Music)
$replacemulti(%_genre%,Oi,Oi!)
$replacemulti(%_genre%,Old school hip hop,Disco Rap)
$replacemulti(%_genre%,Opéra comique,Opéra-comique)
$replacemulti(%_genre%,Opera-ballet,Opéra-ballet)
$replacemulti(%_genre%,Original pilipino music,OPM)
$replacemulti(%_genre%,Palm wine music,Palm-wine)
$replacemulti(%_genre%,Phonk,Rare Phonk)
$replacemulti(%_genre%,Pinpeat,Cambodian Classical)
$replacemulti(%_genre%,Piobaireachd,Pìobaireachd)
$replacemulti(%_genre%,Plainsong,Plainchant)
$replacemulti(%_genre%,Ragga hip-hop,Ragga)
$replacemulti(%_genre%,Rapcore,Rap Rock)
$replacemulti(%_genre%,Rasqueado cuiabano,Rasqueado)
$replacemulti(%_genre%,Rave,Breakbeat Hardcore)
$replacemulti(%_genre%,Reggaeton,Reggaetón)
$replacemulti(%_genre%,Rembetika,Rebetiko)
$replacemulti(%_genre%,Revolutionary opera,Chinese Revolutionary Opera)
$replacemulti(%_genre%,Rhythmic noise,Power Noise)
$replacemulti(%_genre%,Riddim dubstep,Riddim)
$replacemulti(%_genre%,Rock and roll,Rock & Roll)
$replacemulti(%_genre%,Rock andaluz,Andalusian Rock)
$replacemulti(%_genre%,Rock urbano,Rock Urbano Español)
$replacemulti(%_genre%,Romantic classical,Romanticism)
$replacemulti(%_genre%,Romantic,Romanticism)
$replacemulti(%_genre%,Rune singing,Runolaulu)
$replacemulti(%_genre%,Runo song,Runolaulu)
$replacemulti(%_genre%,Saya,Saya Afroboliviana)
$replacemulti(%_genre%,Score,Film Score)
$replacemulti(%_genre%,Scouse house,Donk)
$replacemulti(%_genre%,Sea shanties,Sea Shanty)
$replacemulti(%_genre%,Sertanejo raiz,Sertanejo de Raiz)
$replacemulti(%_genre%,Shan’ge,Shan'ge)
$replacemulti(%_genre%,Shima-uta,Amami Shimauta)
$replacemulti(%_genre%,Skiladiko,Skiladika)
$replacemulti(%_genre%,Song,Lied)
$replacemulti(%_genre%,Song-cycle,Song Cycle)
$replacemulti(%_genre%,Sundanese pop,Pop Sunda)
$replacemulti(%_genre%,Synth-pop,Synthpop)
$replacemulti(%_genre%,Tearout brostep,Tearout [Brostep])
$replacemulti(%_genre%,Technobanda,Tecnobanda)
$replacemulti(%_genre%,Television music,Television)
$replacemulti(%_genre%,Tembang sunda cianjuran,Tembang Cianjuran)
$replacemulti(%_genre%,Tishoumaren,Desert Blues)
$replacemulti(%_genre%,Tone poem,Symphonic Poem)
$replacemulti(%_genre%,Trap edm,Trap [EDM])
$replacemulti(%_genre%,Tsugaru-jamisen,Tsugaru Shamisen)
$replacemulti(%_genre%,UK jackin,UK Jackin')
$replacemulti(%_genre%,Urtiin duu,Mongolian Long Song)
$replacemulti(%_genre%,Vgm,Video Game Music)
$replacemulti(%_genre%,Vikingarock,Viking Rock)
$replacemulti(%_genre%,Waulking song,Òrain Luaidh)
$replacemulti(%_genre%,Western classical music,Classical)
$replacemulti(%_genre%,Western classical,Classical)
$replacemulti(%_genre%,Western,Western Country)
$replacemulti(%_genre%,Whistling,Siffleur)
$replacemulti(%_genre%,Work songs,Work Wong)
$replacemulti(%_genre%,Yue opera,Shaoxing Opera)
$replacemulti(%_genre%,Ancient music,Ancient mmmmm)
$replacemulti(%_genre%,Arabic bellydance music,Arabic bellydance mmmmm)
$replacemulti(%_genre%,Armenian church music,Armenian church mmmmm)
$replacemulti(%_genre%,Background music,Background mmmmm)
$replacemulti(%_genre%,Bass music,Bass mmmmm)
$replacemulti(%_genre%,Beat music,Beat mmmmm)
$replacemulti(%_genre%,Big music,Big mmmmm)
$replacemulti(%_genre%,Bit music,Bit mmmmm)
$replacemulti(%_genre%,Capoeira music,Capoeira mmmmm)
$replacemulti(%_genre%,Cartoon music,Cartoon mmmmm)
$replacemulti(%_genre%,Chamber music,Chamber mmmmm)
$replacemulti(%_genre%,Christmas music,Christmas mmmmm)
$replacemulti(%_genre%,Early music,Early mmmmm)
$replacemulti(%_genre%,Educational music,Educational mmmmm)
$replacemulti(%_genre%,Epic music,Epic mmmmm)
$replacemulti(%_genre%,Ethiopian church music,Ethiopian church mmmmm)
$replacemulti(%_genre%,Flex dance music,Flex dance mmmmm)
$replacemulti(%_genre%,Furniture music,Furniture mmmmm)
$replacemulti(%_genre%,Halloween music,Halloween mmmmm)
$replacemulti(%_genre%,Hill tribe music,Hill tribe mmmmm)
$replacemulti(%_genre%,Holiday music,Holiday mmmmm)
$replacemulti(%_genre%,Incidental music,Incidental mmmmm)
$replacemulti(%_genre%,Islamic modal music,Islamic modal mmmmm)
$replacemulti(%_genre%,Kitchen dance music,Kitchen dance mmmmm)
$replacemulti(%_genre%,Library music,Library mmmmm)
$replacemulti(%_genre%,Light music,Light mmmmm)
$replacemulti(%_genre%,Louisiana music,Louisiana mmmmm)
$replacemulti(%_genre%,Mechanical music,Mechanical mmmmm)
$replacemulti(%_genre%,Mobb music,Mobb mmmmm)
$replacemulti(%_genre%,Mouth music,Mouth mmmmm)
$replacemulti(%_genre%,Nervous music,Nervous mmmmm)
$replacemulti(%_genre%,New music,New mmmmm)
$replacemulti(%_genre%,Nordic old time dance music,Nordic old time dance mmmmm)
$replacemulti(%_genre%,Ottoman military music,Ottoman military mmmmm)
$replacemulti(%_genre%,Outsider music,Outsider mmmmm)
$replacemulti(%_genre%,Production music,Production mmmmm)
$replacemulti(%_genre%,Program music,Program mmmmm)
$replacemulti(%_genre%,Ratchet music,Ratchet mmmmm)
$replacemulti(%_genre%,Regional music,Regional mmmmm)
$replacemulti(%_genre%,Spy music,Spy mmmmm)
$replacemulti(%_genre%,Tamil film music,Tamil film mmmmm)
$replacemulti(%_genre%,Tape music,Tape mmmmm)
$replacemulti(%_genre%,Turntable music,Turntable mmmmm)
$replacemulti(%_genre%,Video game music,Video game mmmmm)
$setmulti(_genre,$rreplace($rreplace(%_genre%,\( folk music;\), fffff;),\( folk music\)\$, fffff))
$setmulti(_genre,$rreplace($rreplace(%_genre%,\( traditional music;\), ttttt;),\( traditional music\)\$, ttttt))
$setmulti(_genre,$rreplace($rreplace(%_genre%,\( music;\),;),\( music\)\$,))
$setmulti(_genre,$replace(%_genre%,mmmmm,Music))
$setmulti(_genre,$replace(%_genre%,fffff,Folk Music))
$setmulti(_genre,$replace(%_genre%,ttttt,Traditional Music))
$setmulti(_genres,$unique(%_genre%))
$setmulti(_genre,$unique(%_genres%))
$setmulti(genre,%_genre%; %period%)
$cleanmulti(genre)

…and finally, 6) Sort genre. This is because my music drive has 14 genre subfolders like Ambient, Classical, Electronic, Hip Hop, Rock & Pop, etc. So I move top level genres (like “Classical” or “Rock”) to the end of the multivariable, and use it to set the proper path for file naming.

$noop(___Add primary genres and place at end of genre multivariable___)
$noop(___Make a copy of the original genre for reference___)
$set(genreOLD,%genre%__________DELETE ME___________)
$if($inmulti(%genre%,Classic Rock),
   $replacemulti(%genre%,Classic Rock,)
   $cleanmulti(genre)
)

$if($or($inmulti(%genre%,Ambient Americana),$inmulti(%genre%,Space Ambient),$inmulti(%genre%,Tribal Ambient)),$set(_lastgenre,Ambient))
$if($inmulti(%genre%,Ambient),$replacemulti(%genre%,Ambient,))
$if($eq(%_lastgenre%,Ambient),$copymerge(genre,_lastgenre))

$if($find(%genre%,Blues),$set(_lastgenre,Blues))
$if($inmulti(%genre%,Blues),$replacemulti(%genre%,Blues,))
$if($eq(%_lastgenre%,Blues),$copymerge(genre,_lastgenre))

$if($and($find(%genre%, Soul),$not($inmulti(%genre%,Soul Jazz))),$set(_lastgenre,Soul))
$if($inmulti(%genre%,Soul),$replacemulti(%genre%,Soul,))
$if($eq(%_lastgenre%,Soul),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Blue-Eyed Soul),$find(%genre%,R&B),$inmulti(%genre%,Doo-Wop),$inmulti(%genre%,Quiet Storm),$inmulti(%genre%,Swamp Pop)),$set(_lastgenre,R&B))
$if($inmulti(%genre%,R&B),$replacemulti(%genre%,R&B,))
$if($eq(%_lastgenre%,R&B),$copymerge(genre,_lastgenre))

$if($or($find(%genre%,Ska),$inmulti(%genre%,2 Tone)),$set(_lastgenre,Ska))
$if($inmulti(%genre%,Ska),$replacemulti(%genre%,Ska,))
$if($eq(%_lastgenre%,Ska),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Dancehall),$inmulti(%genre%,Dub),$inmulti(%genre%,Lovers Rock),$inmulti(%genre%,Mento),$find(%genre%,Reggae),$inmulti(%genre%,Rocksteady)),$set(_lastgenre,Reggae))
$if($inmulti(%genre%,Reggae),$replacemulti(%genre%,Reggae,))
$if($eq(%_lastgenre%,Reggae),$copymerge(genre,_lastgenre))

$if($find(%genre%,Christmas),$set(_lastgenre,Christmas Music))
$if($inmulti(%genre%,Christmas Music),$replacemulti(%genre%,Christmas Music,))
$if($eq(%_lastgenre%,Christmas Music),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Ballet),$inmulti(%genre%,Baroque),$inmulti(%genre%,Classical Period),$inmulti(%genre%,Contata),$inmulti(%genre%,Concerto),$inmulti(%genre%,Fantasia),$inmulti(%genre%,Impressionism),$inmulti(%genre%,Nocturne),$inmulti(%genre%,Opera),$inmulti(%genre%,Sonata),$inmulti(%genre%,Symphony),$inmulti(%genre%,Toccata)),$set(_lastgenre,Classical))
$if($find(%genre%,Classical),$set(_lastgenre,Classical))
$if($inmulti(%genre%,Classical),$replacemulti(%genre%,Classical,))
$if($eq(%_lastgenre%,Classical),$copymerge(genre,_lastgenre))

$if($inmulti(%genre%,Country),$set(_lastgenre,Country))
$if($inmulti(%genre%,Country),$replacemulti(%genre%,Country,))
$if($eq(%_lastgenre%,Country),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Club),$inmulti(%genre%,Downtempo),$inmulti(%genre%,EDM),$inmulti(%genre%,House),$inmulti(%genre%,Glitch),$inmulti(%genre%,IDM),$inmulti(%genre%,Techno)),$set(_lastgenre,Electronic))
$if($or($find(%genre%,synth),$find(%genre%,Synth),$find(%genre%,tronica),$and($find(%genre%,Wave),$not($inmulti(%genre%,New Wave))),$find(%genre%,wave),$find(%genre%,house),$find(%genre%, House)),$set(_lastgenre,Electronic))
$if($eq(%_lastgenre%,Electronic),
   $if($inmulti(%genre%,Electronic),
       $replacemulti(%genre%,Electronic,)
       $copymerge(genre,_lastgenre)
   )
)

$if($or($inmulti(%genre%,Appalachian Folk),$inmulti(%genre%,Celtic),$inmulti(%genre%,Contemporary Folk),$inmulti(%genre%,Old-Time),$inmulti(%genre%,Talking Blues),$inmulti(%genre%,Work Song)),$set(_lastgenre,Folk))
$if($inmulti(%genre%,Folk),$replacemulti(%genre%,Folk,))
$if($eq(%_lastgenre%,Folk),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Afro Trap),$inmulti(%genre%,Afroswing),$inmulti(%genre%,Battle Rap),$inmulti(%genre%,Boom Bap),$inmulti(%genre%,Bounce),$inmulti(%genre%,Crunk),$inmulti(%genre%,Digicore),$inmulti(%genre%,G-Funk),$inmulti(%genre%,Trap)),$set(_lastgenre,Hip Hop))
$if($or($find(%genre%,Hip Hop),$find(%genre%,Rap)),$set(_lastgenre,Hip Hop))
$if($inmulti(%genre%,Hip Hop),$replacemulti(%genre%,Hip Hop,))
$if($eq(%_lastgenre%,Hip Hop),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Bebop),$inmulti(%genre%,Big Band),$inmulti(%genre%,Dixieland),$inmulti(%genre%,Hard Bop),$inmulti(%genre%,Stride),$inmulti(%genre%,Swing)),$set(_lastgenre,Jazz))
$if($find(%genre%,Jazz),$set(_lastgenre,Jazz))
$if($inmulti(%genre%,Jazz),$replacemulti(%genre%,Jazz,))
$if($eq(%_lastgenre%,Jazz),$copymerge(genre,_lastgenre))

$if($or($find(%genre%,rock),$find(%genre%, Rock),$find(%genre%,Metal),$inmulti(%genre%,AOR),$inmulti(%genre%,Mod),$inmulti(%genre%,New Wave),$inmulti(%genre%,Surf),$find(%genre%,Punk),$find(%genre%,punk)),$set(_lastgenre,Rock))
$if($and($inmulti(%genre%,Rock),$eq($get(_lastgenre),Rock)),$replacemulti(%genre%,Rock,))
$if($eq(%_lastgenre%,Rock),$copymerge(genre,_lastgenre))

$if($or($inmulti(%genre%,Production Music),$inmulti(%genre%,Musical)),$set(_lastgenre,Production Music))
$if($inmulti(%genre%,Production Music),$replacemulti(%genre%,Production Music,))
$if($eq(%_lastgenre%,Production Music),$copymerge(genre,_lastgenre))

$setmulti(genre,%genre%)
$cleanmulti(genre)

$set(_lastgenre,$getmulti(%genre%,-1))

$if(%sortgenre%,,$if($find(%_lastgenre%,Christmas Music),$set(sortgenre,Christmas)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Classical),$set(sortgenre,Classical)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Country),$set(sortgenre,Country & Folk)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Bluegrass),$set(sortgenre,Country & Folk)))
$if(%sortgenre%,,$if($find(%_lastgenre%,mbient),$set(sortgenre,Ambient)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Folk),$set(sortgenre,Country & Folk)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Hip),$set(sortgenre,Hip Hop)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Rock),$set(sortgenre,Rock & Pop)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Reggae),$set(sortgenre,Reggae & Ska)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Ska),$set(sortgenre,Reggae & Ska)))
$if(%sortgenre%,,$if($find(%_lastgenre%,R&B),$set(sortgenre,R&B\, Blues\, Funk & Soul)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Blues),$set(sortgenre,R&B\, Blues\, Funk & Soul)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Funk),$set(sortgenre,R&B\, Blues\, Funk & Soul)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Soul),$set(sortgenre,R&B\, Blues\, Funk & Soul)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Jazz),$set(sortgenre,Jazz & Fusion)))
$if(%sortgenre%,,$if($find(%_lastgenre%,Production Music),$set(sortgenre,Production Music)))
$if(%sortgenre%,,$if($find(%_lastgenre%,lectroni),$set(sortgenre,Electronic)))

This last script could use some refinement as I still need to review the genre and adjust it at times. That’s why the unsorted “genreOLD” is included - so I can compare then delete afterward. The “sortgenre” variable is used for the path in filenaming. I also delete “Classic Rock” as I no longer think that’s a proper genre - it’s being deleted at Discogs, also.

When the scripts were finished, I went back and retagged the genres for my (also large) music collection. I made this fairly simple by using Picard’s profiles. I created a new profile that used the keep plugin to ensure only the genre was edited. It took me about 2 to 3 weeks get it done.

HTH

2 Likes

Oh my… Love it!
Just leaving on a side the sorting one, I get what I was looking for.
But now I’m seeing more clearly what are you doing in each one, and think the sorting is a great idea. I want to get my hands on it, to see if I can adjust it to my renaming script (since I have a similar scheme on my collection).
Many, many thanks for sharing and the detailed explanation.

Another question looking at the results…
Is there a way to get every genre on their own frame?
I mean, I’m getting the genres on a single field (semicolon; separated).
Tha’s a problem with MPD, since you get populated every vorbis frame as a genre.
Example: “Folk; Indie Folk” as one genre, “Folk” as another one, and so.

When you manually edit the genre on picard, you has the option to add a value. But when I run the scripts, click/edit the result, I get just one value with all genres.
I don’t know if I’m explaining it well.

What mpd gets well.

What scripts deliver.

If I understand your question, this would be done by placing $setmulti(genre,%genre%) at the end of your script. @ecomaniac has this in their 6th (Sort Genre) script.

The $setmulti() function is explained in the Picard User Guide.

1 Like

To restate what Bob above wrote, your first image shows genre as a multivariable with 3 fields. Your second image shows genre as a single text string in a single field. You have to specify multi-variables per the $setmulti() function.

My media server’s latest software now recognizes multi-variables for certain tags, (like artist & genre) but it didn’t at first. That’s partly why I never bothered with more than one genre per album initially.

2 Likes

Great!
I was avoiding the last sorting script until I get was it does, and tune it up for my needs. Placed a setmulti() on working script and voila!
I’m new to this scripting syntax, still reading the main functions one by one.

1 Like

Exactly. I have what people call ‘a large collection’, and from the first time I get my hands on picard started to tag/rename everything with the same script. I thought this procedure gave me a solid structure, and never gave importance to genres. But recently moved to moode audio, and the way it displays and populate albums brought me to this point. Now I’m in the process of reduce the number of genres to fit my folder structure, retaggin all, and finally get a consistent and neat system.
That’s why I just try’ed the first scripts to undestand it, and then will clean up the hiccup list and sorting script to my needs. I really like the way you sorted out all this.
I think this was discussed earlier, it happened to you that need two scans to get the scripts result?
I mean: load album->lookup->come back tracks to left pane and lookup the cluster again.

Most people (myself included) will recommend that you allow Picard to save the musicbrainz* tags into your files. That way, if you ever need to re-process them, you can simply leave the Ignore MBIDs when loading new files option unchecked, and the album information will be automatically downloaded from MusicBrainz and the files matched to the tracks on the album when the files are loaded. No need to cluster->lookup manually, so it streamlines the process a bit.

3 Likes

I think you’re referring to an inconsistency I found using persistent variables. I was able to resolve that by focusing on the genre result for track #1. So the final script needs load only once.

As an aside, you don’t need to re-cluster the files to reload them - simply press the shortcut “Ctrl-R” and Picard will reload all the default data for the currently selected album release.

1 Like

Getting back to activities!
@rdswift Sure! Tracks already has all the musicbrainz tags, and certainly it autoload everything with just drag an album to picard. But I was ignoring it because it show no changed fields (like scripts not being processed), and manual lookup make it work.
@ecomaniac I think I’m missing something, a setting maybe… Can’t figure out.

Let me be a graphic (I’m struggling with my poor english too :sweat_smile:)
I’ve started clean again. Just pasted the scripts, disabled all plugins but Persistent Variables, and disabled the Genres section in preferences.

I drop an album, picard autoload the info about it.
Genre field shows no changes, no new data to be written.
(refresh, Ctrl-R don’t change this)

Drop it to the left, make a lookup.
Now there’s two genres ready to write.

Now if I repeat the procedure, a second lookup gives five genres listed.
I don’t really need the whole genres, but makes me think the number of genres listed has direct relation with the number of tracks in an album. Is that right? :thinking:

Now installed the View Script Variables plugin, and check it on the first track.
When an album is loaded without any intervention, it shows persistent variables are present.

But it hasn’t go through the loop…

A manual lookup shows the variables working.

What I’m doing wrong?

Did you set up a new profile, or are you using your default profile?

“Use genres from Musicbrainz” should be enabled. “Use only my genres” should be unchecked. My “minimal genre usage” is set to 0% so all genres are provided. “Max number of genres” is set to 5, and the joiner character is a semicolon “;”.

Have you made any edits to the scripts? If so, post them. Are the scripts in the same order as above?

This is jogging my memory from when I changed all my genres. My first genre result was occasionally (like 1 in 10) different across the tracks like your first graphic. But a Ctrl-R always fixed it.

Looking at the counts, your second result is the correct one. I’m surprised Ctrl-R didn’t work for that. Is Ctrl-R working? You can tell by watching the release briefly go into ‘loading album info’ mode.

Reloading a second time adds the next higher count genres for some reason. It looks like your album has 14 tracks, so anything with a count less than 7 shouldn’t persist per my 3rd script above. I haven’t tested loading more than 5 genres, so there may be some unexpected behavior. I’ve also noticed reloading files is not clearing the variables in memory. For consistency, you should review changes with a fresh instance of Picard.

3 Likes

It’s working now! :boom:
Yesterday I’ve disabled plugins and the genres section just to check out, and behaviour was the same. Now I enabled it again, my settings already was the same as yours (dedicated profile, settings, scripts) BUT, think I’ve undestood the ‘minimal usage’ meaning. Mine was setted at 95%, changed to 0% and worked. I’m still can’t undestand why.
Just out for curiosity, variables are not cleared if I do a re lookup. It doesn’t really matter now that it’s working as expected.
Think I’m ready to start the mass rewrite, love it!
Thank you!

2 Likes

4 posts were split to a new topic: Sum up numeric tags across multiple tracks