Copy part of Artist to Title

I've just finished tagging my apple lossless library with an artist value of eg "OutKast; Jay-Z" and a band tag of eg "OutKast" as this works as I want in iTunes and SqueezeCenter.

I then batch convert to mp3 for iPod. Sadly iPod doesn't pick up the band field, despite iTunes doing so, so now my iPod browsing is really screwed!

I need to somehow remove all bar the main artist from the artist fields, and copy the remainder to the end of the title.

Title = In Your Dreams
Band = OutKast
Artist = OutKast; Killer Mike; Janelle Monáe

Title = In Your Dreams [Feat. Killer Mike; Janelle Monáe]
Band = OutKast
Artist = OutKast

I know this should be possible with RegEx, and I've tried but I really, really can't get my head round RegEx! So a plea for help please!

A caveat...
Artist field can have any number of artists in it, but the main one is always first.
Values entered into artist field exactly as written, ie use of semi-colon followed by space to seperate artists.
Obviously there's no way text-matching or length-matching will work; the artist field can contain anything!


Ah, finally worked it out. Just my other post on the if function to go now!

Care to elaborate those who might be dealing with the same issue..?

Yes. Yes I do! A clunky solution, but a solution nonetheless. Action's attached. What it does...

1 Copies contents of %artist% to %wwwartist%

2 Copies contents of %title% to %wwwaudiofile%

3 Copies contents of %artist% to %www% (I use %www% as a "working-area" tag for things like this)

4 Replace with regular expression "WWW": "^(.*?);\s" -> "" to remove everything up to and including the space after the first semi-colon (it won't, sadly, remove any entries where the artist didn't have any multi entries, I'm not very good at RegEx. But the next step takes account of this!)

5 Format %title% thus: if contents of %www% are the same as %artist%, leave title alone. Otherwise append end of title with contents of %www% thusly: " [Feat. %www%]"

6 Remove the "working" %www% field

7 Copy contents of %band% to %artist%

Steps 1 and 2 are "safeties" (I've just picked a couple of arbitrary tags that don't get wiped out by any of the apps I use) so that the whole thing can be easily undone if Apple fix the fact that the iPod doesn't use %band%! I've attached that action for good measure, but it's very simple.

I'm 100% certain that there are more elegant ways to do this, but it works for me!

Note that it will only work in this form if your artist fields are laid out as per mine in post 1. You can alter the RegEx to replace ; with your separator if different (I rip using dBpoweramp, which I've told to use ; in preference to a "proper" (well, I know Apple lossless doesn't support proper multi-fields) multi separator, in order to keep iTunes and SqueezeCenter happy).

I'm really chuffed, I managed to figure out a bit of RegEx. Did take me about 3 hours though! Thanks to newser for help with the $if function, by the way.

Format_multi_artist_files_for_iPod.mta (294 Bytes)

Use_on_mp3s_once_iPod_BAND_is_fixed_.mta (120 Bytes)

The tag field BAND will not be touched, so we have only to work with the tag fields ARTIST and TITLE.
You will cut and paste a substring from ARTIST to TITLE.
This can be done in Mp3tag in different ways using Mp3tag scripting functions.
Here comes a proposal that uses the $RegExp function.

Begin Actionsgroup moley6knipe
Action #1
Actiontype 5: Format tag field
Field: TITLE
Formatstring: %title%÷'['$regexp(%artist%,'^.+?;\s(.*)$',$1)']'

Action #2
Actiontype 5: Format tag field
Formatstring: $regexp(%artist%,'^(.+?);\s.*$',$1)

Note: Replace one special character ÷ with one space character.
End Actionsgroup moley6knipe (2 Actions)

There is no need to have other tag fields involved in the process.

Basically you should avoid to abuse normal standard tag fields for storing intermediate results.
You are free to define tag fields with your own names e. g. TMP, TEMP1, TEMP2, MY_TAG, YOUR_TAG, BLACK, WHITE, HOT, COOL, FEAT, DELETE and so on ... you can remove such user defined tag fields later in the process.


This is a good example of how nice it would be to have an 'Exit action group' action type. If BAND=ARTIST you could exit immediately, without having to execute the rest of the actions and rewrite both the ARTIST and TITLE fields with the same values.

Action type: Exit action group
Conditon: $eq(%artist%,%band%)

This works a little better. You can execute it more than once on a file without getting multiple [Feat. ...] and you won't get a trailing space appended to the title.

Action type: Format value
Field: TITLE
Format string: %title%$if($neql(%artist%,%band%),÷'['Feat.÷$regexp(%artist%,^.+?;\s(.*)$,$1)']',)

As above, replace the ÷ characters with spaces.


See, I knew some kind soul would come along and take pity on my fumbling! Thanks for all the input guys; it's way, way, above my head but the more I play around with these things the more I understand them. The bit of RegEx that confuses me most is all of these $,$1 bits. I'll try these actions out, thanks!

Yeah, I know I should avoid using such fields :frowning: . I've got in the habit of doing it because I use dBpoweramp for batch conversion, and it's got bugs with it's implementation of apple lossless. It deletes things like the albumsortorder field when I batch convert from apple lossless to mp3, so I've taken to storing a "safety copy" of such tags in things like the wwwaudio tags. Likewise if I create a temp tag on an apple lossless file in mp3tag, dB wipes it out!

Thanks for all the input again folks!