Replaceing / Deleting Stings with Regular Expressions

Hello Everyone

I am new to the MP3TAG forum. Greets! I have what I am sure is a simple question but for the life of me I have been unable to find an answer. I just cant get my head around regular expressions as implemented in MP3TAG. I have read many posts and have not found a clear answer to this question.

I have a bunch of MP3's in the format of - .mp3 for example,
an MP3 named Bob James - Reunited.mp3. I would like the title to end up being just
Reunited.mp3. I would like to DELETE or REMOVE all characters starting from the beginning of the string up to the first "-". I cannot figure out how to do such a simple thing.

I would also like to know how to do the opposite, by that I mean I would like to be able to search for the first instance of "-" and REMOVE or DELETE all text AFTER that instance to the end of the string.

If anyone could help me out with EITHER expression it would be GREATLY appreciated. I have been missing around with this for over a month ( it was a personal challenge :slight_smile: but I just cannot get it to work.

I am using MP3TAG v 2.46

Any response is greatly Appreciated.


Your request sounds similar to this thread ...


Yes it is very similar. And I see he never got an answer either :slight_smile:

IS there a simple solution to this question?

I take it that you are somewhat allergic to regular expressions.
So if your filename looks like - .mp3
you can easily rewrite your tags by importing the right section with the function filename - tag:
The mask looks lke this:
%artist% - %title%
The preview should re-ensure you to get the right result.
If you still want a solution with regular expressions you have to come back to this thread.

Thank you for your reply Ohrenkino. Yes for the moment I am 'allergic' to RE's. I would really like to learn tho. This could be a very useful tool if I could figure it out. I am more than willing to give it a try tho. I just need a bit of guidance :slight_smile: To explain further, my MP3's, have NO OTHER ID3 TAG Information other than TITLE and ARTIST information. Everything else is blank.

For Example:

ID3 Tag Artist: Groovy Music
ID3 Tag Title: Bob James - Reunited

So I would like to start arranging the ID3 tag information so I can use CDDB or somthing similar to fill-in in as much ID3 information as possible. So next I replaced the ARTIST tag with the TITLE tag. Now my ID3 information looks like this ....

ID3 Tag Artist: Bob James - Reunited
ID3 Tag Title: Bob James - Reunited

Next I would like to fix the information in the ID3 tag fields. I would like to remove 'Bob James -' from the Artist field and I would like to remove '- reunited' from the Title Tag so that it would end up like so

ID3 Tag Artist: Bob James
ID3 Tag Title: Reunited

IDEALLY I would like to fill in the TITLE tag from the Filename information but that is another topic. I hope this is a bit more clear.

Ohrekino Thank you for your replay but I do not understand what you are saying. Where would I APPLY this MASK? It would appear that mask will just reverse the TITLE and ARTIST tags. That is not quite what I am trying to do ....

Thank you for your reply!

Sure, there are answers, even to your problem situation.
Renaming/Removing Items From Tags


Thank you for your reply DetLevD. Can you perhaps tell me how to do what you are suggesting? At least tell me where the menu options are? I apolgize for being a Noob and asking questions but everyone must start somewhere. I did not create this software and I am not intimately familiar with every menu option and it's use.

Thank you for your reply.

Yes, you are right, so start Mp3tag, load and select a test file and browse through the menus, look around what is offered to you, learn the names of menu items and what the items will do. Read the help manual.

From my side it is all said how to use Mp3tag in the given cases and where to find the functionality in Mp3tag, which I have described how to use.


I have tried what you referred me to in the previous post. It appears as if this will change the actual FILENAME. I am not interested in changing the FILENAME but the ID3 tag fields. I wopuld like to change the Artist and Title. If I do this as mentiond to try

Supposing that the tag fields ARTIST and TITLE are empty or do contain erasable informations, and the filename contains the information for setting the tag fields ARTIST and TITLE, then you can use Mp3tag/Convert/Filename-Tag.

With a given filename of "artist - title.mp3", where "artist" stands for the textual information about the artist and "title" stands for the textual information about the title, both parts separated by a literal string of ' - ', which is unique to the both informations parts, then you can use the following format string (or mask) to fill the tag fields automatically with the related content from the filename:

And PREVIEW the results, the results show I am changing the FILENAME. I do not wish to change the FILENAME. I want to change ID3 TAG informations. At least it appears to me.

It is not clear to what text passage of the offered solutions you reply now.

Please use the quoting function of this forum board when you are quoting passages from other user's posting.

Well, then change the tag fields.
I have all layed out what Mp3tag beginners can easily use.
"Filename-Tag" and "Tag-Filename" should help perfectly in your situation.

When you have learned to work with these both beginner dialogs in an error free manner, then we can speak about using Mp3tag scripting functions and even about using of Regular Expressions in order to do the same tasks another way but not simpler at all.

What you say is not correct.
The dialog "Filename-Tag" offers a "Preview", which shows the content of the tag fields in question (which could be detected and broken down by the given format string), how they will be physically filled when the process "Filename-Tag" has been accepted.


Never mind then. I just dont understand forums like these. You put them here so people can ask for help with software that you have taken the time and trouble to produce and then get mad when people ask legitimate questions I am not in ANY WAY trying to say or imply anything BAD about your software. You have NO NEED to be SO DEFENSIVE. I am simply asking a question about how to use your software in a way I cannot figure out.

Sorry to have wasted your time, it would appear this software cannot perform this SIMPLE task.

Thank you for your support

There might be another way too to help you over the hurdle.

Create a group of actions ...

Begin Actionsgroup Test#20100320.DrWho

Action #1
Actiontype 7: Import tag fields (guess values)
Source format: %ARTIST%
Guessing pattern: %ARTIST%÷-÷%DUMMY%

Action #2
Actiontype 7: Import tag fields (guess values)
Source format: %TITLE%
Guessing pattern: %DUMMY%÷-÷%TITLE%

Note: Replace each special ÷ character with one space character.
End Actionsgroup Test#20100320.DrWho (2 Actions)

... and run it against your files which follows your example from above, i. e.
ARTIST = "Bob James - Reunited"
TITLE = "Bob James - Reunited"

The result will be ...
ARTIST = "Bob James"
TITLE = "Reunited"

A last advice:
Read the help manual.
Read through this forum and learn from the questions of other users.
Try out the Mp3tag world for yourself.


The previously quoted message shows, that an error can happen even in the moment when someone will do it perfectly.

The formatstring %ARTIST%' - '%TITLE% is bad.
The formatstring %ARTIST% - %TITLE% is good.

I apologize for the despair while my proposal has not worked as desired.


If someone will go the Mp3tag scripting way, then the following scripting strings, used together with Action "Format value", will give the same results as the "Guessing values" actions from above post #12.

ARTIST = "Bob James - Reunited"
ARTIST = "Bob James"
$left(%ARTIST%,$sub($strstr(%ARTIST%,' - '),1))

TITLE = "Bob James - Reunited"
TITLE = "Reunited"
$right(%TITLE%,$sub($len(%TITLE%),$strstr(%TITLE%,' - '),2))


Using the scripting function $regexp() together with Action "Format value" looks like following:

ARTIST = "Bob James - Reunited"
ARTIST = "Bob James"

TITLE = "Bob James - Reunited"
TITLE = "Reunited"


Using Action "Replace with Regular Expression" looks like following:

Begin Actionsgroup Test#20100320.DrWho (1)

Action #1
Actiontype 4: Replace with regular expression
Regular expression: ^(.+?)\s-\s.+?$
Replace matches with: $1

[_] Case sensitive comparison

Action #2
Actiontype 4: Replace with regular expression
Field: TITLE
Regular expression: ^.+?\s-\s(.+?)$
Replace matches with: $1

[_] Case sensitive comparison

End Actionsgroup Test#20100320.DrWho (1) (2 Actions)