Remove spaces from tags

I want to remove spaces from a tag but all that I've tried so far either removes the complete tag or inserts charachters that I don't want. Now I beg for an idea how to do it correctly. There are two problems to be solved. One: A great number of tags contain leading and/or trailing spaces. These I want to remove and this should work when there is only a leading space or only a trailing space or both of them. Two: Sometimes there are two spaces in sequence within a tag and here I want to erase one of these spaces.
Too difficult ? Well, yes as far as I'm concerned.

Please help me with a solution. Please don't assume that I am too familiar with regex and thos things, otherwise i wouldn't have asked. I use Mp3tag 2.83 and you may answer as well in German.

senior

Directly above this post there's a link to the Frequently Asked Questions: #howto:faq-frequently-asked-questions

You'll find the answer there under actions.

And many other basic functionalities of Mp3tag.

Although the answer there could be short handed to one action to.

Action type: Replace with regular expressions
Field: _TAG
Regular expression: ^\s*|\s*$
Replace matches with:

Many thanks for the link to this tutorial which I must have overlooked as my search was more or less resultless. I'll go through these instruction and hope that I'll get along all by myself. Should I not succeed I'll ask again.

Have a nice weekend
senior

Could you show us what you have done so far? Perhaps we can start there and you get a better idea what has to be done.
Also, I would like to draw your attention to the help, in this case "scripting" https://docs.mp3tag.de/scripting and the $trim() function.

First of all: With the tutorial I was able to remove those spaces that I didn't want.
My problem was (and still is) that I am absolutely dumb as to regex expressions. So it was necessary that I found something matching which I did. One problem was, that I triggered other actions before I noticed that I have to uncheck all other actionsgroups in the list. Here the undo function was of great help. Apparently other stored actions will be executed when they are in sequence with the wanted one and when they are checkmarked. What the checkmark is for, I still don't fully understand. Here is how my new actions look like (sorry they are in German as this is my native language)




Thank you all for your help
senior



If you only want to treat single/specific fields then it might be just as easy to use the $trim() function in an action of the type "Format value"
Field: ARTIST
Format string: $trim(%artist%)
No regular expression required.

you can actually filter for such fields:
"$if($eql($len(%artist%),$len($trim(%artist%))),1,0)" IS "0"
(replace the %artist% with any other field name that you want to check)

The check boxes in the actions list enable you to create your own jobs when executing actions:
You can compose the action groups in the required number and sequence (move them up and down in the list) to cater for specific tasks. Like this you do not have to call the same actions over and over again. MP3tag allows you to be as modular as you like.

When I understand the filter expression correcly then the given example trims the leading first character of a string. Thank you for explaining the check boxes to me, that was very helpful for my understanding.

senior

Not quite:
THe filter evaluates the length of the string in the field (in this example) ARTIST and compares it with the length of the string in the field ARTIST after the leading and trailing (both!) have been cut.
Like this you find all the strings that have either leading or trailing blanks.

I slowly get the picture. Thanks for your patience!

Within the dialog "Action groups", at the top of the list of actiongroup names, I have inserted an everlasting check marked actiongroup entry called "NO_ACTION", without any internal action defined, ... it is just a placeholder doing nothing.
All following other defined actiongroups have no checkmark.

You can call an actiongroup by the Mp3tag menu "Actions" [Alt+A], then select a defined entry from the list of actiongroups.

For example, define an actiongroup to remove leading and trailing spaces from all tagfields within the entire TAG, having only one entry.
Name this actiongroup to: &MyActions#Trim leading trailing &spaces (_TAG)
Field: _TAG
Regular expression: ^\s+|\s+$(?#remove leading trailing spaces)
Replace matches with:
case sensitive comparison: no

Afterwards this action group can be called by the Mp3tag menu [Alt+A] Actions etc., ...
or directly by the keyboard combination [ALT+AMS].

DD.20170709.1426.CEST

Thank you for providing such detailed information on that matter. Mp3tag is a very mighty tool but it requires a lot of knowledge, more than is provided in tutorials and help files. Therefore I appreciate such step-by-step guidance all the more when it contains an explanation of what happens.

senior