# \[X\] Spaces at the beginning and end of tag fields

**URL:** https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836
**Category:** No Bugs
**Created:** [September 3, 2012, 4:41pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836 "2012-09-03T16:41:15Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 3, 2012, 4:41pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/1 "2012-09-03T16:41:15Z")

</div>

I'm not sure if this could be considered a bug, but it really **bugs me**. 😉

If I accidentaly select a space before or after the text which I'm copying to any of the tags, it will be saved. For example, if I copy an artist's name from the internet and accidentally select a space before it (very easy to do in a body of text), that space will become the first character of the artist field after saving it, and that artist will show up first when sorting artist names in a list in any audio manager. Also, it's very easy to overlook such things while viewing files in Mp3tag, and it seems to do this for any tag field.

I don't know if there is any special case in which having spaces at the beginning or end of tags would be justified, but if there isn't I would like to recommend changing Mp3tag's default behaviour to deleting those spaces when saving, similar to the way Windows automatically delete them when you try to rename a file.

Other than that, Mp3tag seems pretty much flawless. 😃

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [September 3, 2012, 5:39pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/2 "2012-09-03T17:39:04Z")

</div>

> [@aax](#):
>
> ... having spaces at the beginning or end of tags ...

I am quite glad that MP3tag does not interfere with my input even it is somewhat stupid.  
You can find files with leading or trailing blanks (in ARTIST) with the following filter:  
"$if($eql($len(%artist%),$len($trim(%artist%))),1,0)" IS "0"

You can get rid of these blanks with an action of the type  
"Format tag field"  
and the format string  
$trim(%artist%)

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 3, 2012, 10:13pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/3 "2012-09-03T22:13:50Z")

</div>

All right, no offense, but I just thought there is no reason for those spaces and they can easily mess things up. But, hey, if there's an action for that, I'm good.

So, what exactly does $trim do?

---

<div class="post-metadata">

### Author: ![mjcm](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/9d8465/32.png) [@mjcm](https://community.mp3tag.de/u/mjcm)
#### Post date: [September 4, 2012, 1:45am UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/4 "2012-09-04T01:45:24Z")

</div>

> [@aax](#):
>
> So, what exactly does $trim do?

Trim will remove any leading or trailing blank spaces from a string. So if the string was **" Text"** , then Trim would delete those spaces for you, leaving just **"Text"**.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [September 4, 2012, 4:06am UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/5 "2012-09-04T04:06:57Z")

</div>

> [@aax](#):
>
> ... So, what exactly does $trim do?

Read about the _functions_ $trim, $trimLeft, $trimRight in the manual ...  
[https://docs.mp3tag.de/scripting](https://docs.mp3tag.de/scripting)

DD.20120904.0806.CEST

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 4, 2012, 2:58pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/6 "2012-09-04T14:58:50Z")

</div>

Thanks, both of you.  
By the way, is there a way to do this for all of the tags in a file?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [September 4, 2012, 3:57pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/7 "2012-09-04T15:57:12Z")

</div>

you could use %\_all% but I wouldn't esp. if you have lyrics somewhere

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [September 4, 2012, 4:26pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/8 "2012-09-04T16:26:16Z")

</div>

> [@aax](#):
>
> By the way, is there a way to do this for all of the tags in a file?

[/t/967/1](https://community.mp3tag.de/t/967/1)

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 4, 2012, 5:21pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/9 "2012-09-04T17:21:02Z")

</div>

Thanks

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [December 28, 2018, 2:32pm UTC](https://community.mp3tag.de/t/x-spaces-at-the-beginning-and-end-of-tag-fields/13836/10 "2018-12-28T14:32:10Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
