extracting expressions from one field to place in another?

Hello,

I could not find any information on this and I'm not entirely sure how to describe it but here goes.

mp3 title - "I know [Amurai Remix]"
mp3 artist - "George Acosta Feat. Tiff Lacey"

I already have many custom actions set up to format my mp3's but I like to have secondary artist information within the song title.

So for example the TITLE needs to become "I know [Feat. Tiff Lacey][Amurai Remix]"

I'm not sure if this is possible and if it is, which action to use? I can't simply write the %artist% to %title% as I only want the "Feat. Tiff Lacey" Part.

Can anything be done or will I have to do this part manually?
Thank you, Steven.

I think your modification takes several different actions as there are several steps.

As the "[" is unique in %artist% you can find its position with the scripting function $strstr
Replace string would look like:
%title% $mid(%artist%,%strstr(%artist%,[),$len(%artist%))

As this action appended the featured artist at the end of title you have to swap the contents in the chevrons and the contents in the square brackets. Do this with an action of the type "Replace with regular expression"
The find expression for the field title would be:
(.)([.]) ([.*])
the replace pattern is:
$1$3 $2

For such an example case you can try a group of actions ...

Begin Actionsgroup Test#20100315.Cunniffe66 (1)
Action #1
Actiontype 7: Import tag fields (guess values)
Source format: %ARTIST%
Guessing pattern: %DUMMY%÷Feat.÷%TMP_1%

Action #2
Actiontype 7: Import tag fields (guess values)
Source format: %TITLE%
Guessing pattern: %TMP_2%÷[%TMP_3%]

Action #3
Actiontype 5: Format tag field
Field: TITLE_NEW
Formatstring: %TMP_2%'÷[Feat.÷'%TMP_1%']['%TMP_3%']'

Action #4
Actiontype 9: Remove fields
Fields to remove (semicolon separated): TMP_1;TMP_2;TMP_3

Note: Replace each special ÷ character with one space character.
End Actionsgroup Test#20100315.Cunniffe66 (1) (4 Actions)

DD.20100315.1149.CET

It is possible to shorten the action group ...

Begin Actionsgroup Test#20100315.Cunniffe66 (2)
Action #1
Actiontype 7: Import tag fields (guess values)
Source format: %TITLE%|%ARTIST%
Guessing pattern: %TMP1%÷[%TMP2%]|%DUMMY%÷Feat.÷%TMP3%

Action #2
Actiontype 5: Format tag field
Field: TITLE_NEW
Formatstring: %TMP1%'÷[Feat.÷'%TMP3%']['%TMP2%']'

Action #3
Actiontype 9: Remove fields
Fields to remove (semicolon separated): TMP1;TMP2;TMP3

Note: Replace each special ÷ character with one space character.
End Actionsgroup Test#20100315.Cunniffe66 (2) (3 Actions)

DD.20100315.1912.CET

And even shorter ...

Action #1
Actiontype 5: Format tag field
Field: TITLE
Formatstring: $regexp(%TITLE%'---'%ARTIST%,'^(.+?)\s[(.+?)]---(?:.+?)\sFeat.\s(.+?)$','$1÷[Feat.÷$3][$2]')

Note: Replace each special ÷ character with one space character.
End Actionsgroup Test#20100315.Cunniffe66 (3) (1 Action)

Note:
It is good practice to test someone's proposal with a test file before running the whole library into hell.
Also good idea is to filter the amount of files at first to get only the set of files that match the rule and then run the actiion against the set of candidate files.

DD.20100315.1934.CET

Thank you both for the quick reply, I will try the suggestions and get back to you.

Steven.

[quote="Cunniffe66_, post:4, topic:10104"] Thank you both for the quick reply, I will try the suggestions and get back to you.

Steven.
[/quote]

[u]@Ohrenkino
I'm not sure what you mean by 'chevrons'
Also, I wasn't sure how to enter the formula you posted. I did the following

Action1: Replace
Field: ARTIST
Original: %artist%
Replace With: %title% $mid(%artist%,%strstr(%artist%,[),$len(%artist%))
Only as whole word: NO
Case Sensitive: NO

Action2: Replace with Regular Expression
Field: TITLE
Regular Expression: (.)([.]) ([.*])
Replace Matches With: $1$3 $2

Is This Incorrect because it didn't work?

@DetlevD
I didn't have success with your methods. :frowning:

For Method1 (with 4 actions): Nothing changed when tested on Album + sample Mp3
For Method2 (with 3 actions): Nothing changed when tested on Album + sample Mp3
For Method3 (with 1 action) : The full Artist string was added to the end of Title string with a "---" in between. For Example:

Mp3 Title: Voodoo People [Pendulum Remix]
Mp3 Artist: The Prodigy
became
Mp3 Title: Voodoo People [Pendulum Remix]---The Prodigy
Mp3 Artist: The Prodigy

Also, when tested on the sample Mp3

Mp3 Title: I know [Armurai Remix]
Mp3 Artist: George Acosta Feat. Tiff Lacey
became
Mp3 Title: I know [Feat. Tiff Lacey][Armurai Remix]
Mp3 Artist: George Acosta Feat. Tiff Lacey

This example is a different case than the first one, for which the actions were made.
This example needs other effort. Because the Artist tag field has no "Feat.", there is no splitting possible and the expression gives faulty result.

That is why I recommended to filter the tracks first to get a set of only those tracks that matches the rules and which are able to be treated well by the proposed actions.
You cannot treat apples like peaches, but you have tried, and you have failed.

This is accurate the result of what you have described in your post.

"Nothing changed" is not correct, you got at least a new tag field TITLE_NEW.
I did this for the case if you are to foolish and you have selected tracks that do not match the rules, simply to prevent overwriting of the original TITLE tag field with garbage.
I've let you the chance to change the action formula from tag field TITLE_NEW to tag field TITLE if it works as expected.

Because you wrote in your request for support ...

... I've expected you know what you do and you have learned to use Mp3tag.

And to say my last words ... I gave you much insight in methods and tools how Mp3tag scripting and action functions can be used - and ohrenkino too. Now you should be able to combine the best and solve your text editing problems for yourself.

DD.20100316.2252.CET

I appreciate your point, I do not understand the dynamics of the expression that you suggested. That is why I ran it on 'peaches' as you say. I was unsure whether or not it was compatible with tracks that lacked a featured artist in the artist field.

My mistake, I believed your use of "title_new" was to temporarily store a string as part of the action. Thank you for trying to protect me from my own foolishness but I had the foresight to create a copy of an album solely for the purpose of testing these actions.

Thank you for your time, In retrospect the 1-action regular expression you provided does fit the purpose of the problem I explained earlier and for that I am very grateful. However I now realise that I didn't mention that "feat. tiff lacey" should be removed from the ARTIST field.

As I said before I don't quite understand the dynamics of the regular expression - If you could suggest an action to remove "feat. tiff lacey" from the artist field that I can combine with the current action that would be very much appreciated. Though if you feel that you've spent enough time on this already I understand.

Thank you, Steven.

Well, to remove the string part "Feat. abc" from the ARTIST tag field you can do following:

  • Regarding both proposals which use the 'guess values' actions, you simply can replace the word "%DUMMY%" with the word "%ARTIST%".
  • Regarding the proposal to use a regular expression you can use an additional regular expression:
    Field: ARTIST
    Format string: $regexp(%ARTIST%,'^(.+?)\s(?i)Feat(?-i).\s(?:.+?)$','$1')

DD.20100317.0830.CET

Thank you, I now have the results I desired. I am grateful for your assistance.