... and here it goes ...
Note:
If we could sort a delimited itemlist within a tag-field, Mp3tag life would be much easier!
If we could repeat one action in a loop, Mp3tag life would be much easier!
Example itemlist:
ITEMLIST="aaa,aaa,aaa,bbb,ccc,bbb,ddd,ddd,ddd,ccc,eee,fff,GGG,ggg,iii"
The itemlist contains 15 items:
"aaa" x 3, "bbb" x 2, "ccc" x 2, "ddd" x 3, "eee" x 1, "fff" x 1, "GGG" x 1, "ggg" x 1, "iii" x 1.
This regular expression:
$regexp(%ITEMLIST%,'(?:^|,)([^,]*)(,\1)+(?=,|$)','$2')
will reduce the itemlist by removing adjacent duplicate items
from:
"aaa,aaa,aaa,bbb,ccc,bbb,ddd,ddd,ddd,ccc,eee,fff,GGG,ggg,iii"
to:
",aaa,bbb,ccc,bbb,ddd,ccc,eee,fff,GGG,ggg,iii"
This regular expression:
$regexp(%ITEMLIST%,'(?:^|,)([^,]*)(.*)(,\1)+(?=,|$)',',$1$2')
will further reduce the itemlist by one duplicate pair
from:
",aaa,bbb,ccc,bbb,ddd,ccc,eee,fff,GGG,ggg,iii"
to:
",aaa,bbb,ccc,ddd,ccc,eee,fff,GGG,ggg,iii"
There are still some duplicate items in the itemlist.
Mp3tag cannot execute an action in a loop, so we have to sequentially repeat this step.
How much? Use a count that fits to your needs.
After some steps the itemlist will be reduced
from:
",aaa,bbb,ccc,bbb,ddd,ccc,eee,fff,GGG,ggg,iii"
to:
",aaa,bbb,ccc,ddd,eee,fff,GGG,ggg,iii"
Surrounding comma can easily be trimmed by
$trim(%ITEMLIST%,',')
Now the itemlist contains nine unique mixcased items:
ITEMLIST="aaa,bbb,ccc,ddd,eee,fff,GGG,ggg,iii"
If the process should not respect mixcased items, that means ignore mixcased spelling, then the regular expressions need a modification:
$regexp(%LIST%,'(?i)(?:^|,)([^,]*)(,\1)+(?=,|$)','$2')
$regexp(%LIST%,'(?i)(?:^|,)([^,]*)(.*)(,\1)+(?=,|$)',',$1$2')
This will reduce the itemlist
from:
"aaa,aaa,aaa,bbb,ccc,bbb,ddd,ddd,ddd,eee,fff,GGG,ggg,iii"
to:
",aaa,bbb,ccc,ddd,eee,fff,ggg,iii"
Put all steps into an action group:
Test_2010_20100921.RemoveDupItems.mta (1021 Bytes)
Now it is possible to do ...
From:
ITEMLIST="Female Vocalists, Indie, Indie Rock, Alternative, Rock, Indie Pop, Pop/Rock, Alternative Rock, Punk, Indie Rock, Alternative/Indie Rock, Alternative Pop/Rock, Fun, Garage Rock Revival, Alternative Rock, Bright, FUN, Stylish, Uplifting, Nostalgic, Exciting, Fun, Girls Night Out, FUN, Breakup, Indie Rock"
To:
ITEMLIST="Female Vocalists, Indie, Indie Rock, Alternative, Rock, Indie Pop, Pop/Rock, Alternative Rock, Punk, Alternative/Indie Rock, Alternative Pop/Rock, Fun, Garage Rock Revival, Bright, Stylish, Uplifting, Nostalgic, Exciting, Girls Night Out, Breakup"
... alas ... still not sorted!
DD.20100921.0930.CEST