Most of my music files have a MUSICIANCREDITS (for FLAC) or TMCL (for MP3) tag. The value of the field is a list of null-separated pairs, where each pair consists of an instrument and a musician, separated by a NULL. This is as prescribed by the MP3 tagging spec. My intent is to parse that field to provide a replacement for a multiple artist field (as soloists in the standard MC scheme).
First step is to define a MUSICIANCREDITS field as text and import the values from the file tags. MC replaces the NULLs in the field value with \x0D\x0A when reading the raw tag, which is fine. Then, I replace all those newlines with a semicolon, which I can do in an expression column with:
replace([MUSICIANCREDITS],/#
#/,;)
where the newline is escaped by the slash-sharp sequence. The first problem is that I cannot figure out how to do that in a calculated field expression, as I cannot insert the newline character (typing it closes the dialog, cut-and-paste stops at the newline).
The next step is to pick-up only the soloists, not the instruments. Converting to a list like in
listcombine([MUSICIANCREDITS],,/#
#/,;)&datatype=[list]
removes all duplicates and leaves you with a list which has each instrument and each soloist. Is there a simple way to remove the instruments (assuming I know exactly all the possible instruments)?
Alternatively, I could replace every other newline with a backslash, and the other newlines with a semicolon, to get a hierarchy instrument->soloist. But I can't figure out how to do that for 2 reasons: can't figure out how to put a newline in a regex, and can't figure out how to do global replacements using regex.
Am I missing the obvious? Thanks for any suggestion.