# How to remove whitespace right to a string based on its length?

**URL:** https://community.mp3tag.de/t/how-to-remove-whitespace-right-to-a-string-based-on-its-length/67234
**Category:** Export
**Created:** [January 22, 2025, 1:44am UTC](https://community.mp3tag.de/t/how-to-remove-whitespace-right-to-a-string-based-on-its-length/67234 "2025-01-22T01:44:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tor11](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tor11](https://community.mp3tag.de/u/tor11)
#### Post date: [January 22, 2025, 1:44am UTC](https://community.mp3tag.de/t/how-to-remove-whitespace-right-to-a-string-based-on-its-length/67234/1 "2025-01-22T01:44:48Z")

</div>

This is for export to a txt file.

The idea is to simply count the number of chars `$len(%genre%)` and trim the corresponding white space chars to the right, so the right border aligns again.

```auto
 ___________________________________________
| Artist: %artist% |
| Genre: Classical -->|

```

```auto
 ___________________________________________
| Artist: %artist% |
| Genre: Classical <--|

```

Can someone help with this function?

---

<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: [January 22, 2025, 7:27am UTC](https://community.mp3tag.de/t/how-to-remove-whitespace-right-to-a-string-based-on-its-length/67234/2 "2025-01-22T07:27:50Z")

</div>

> [@tor11](#):
>
> Can someone help with this function?

I don't see a function.

The real, current code would help a lot.

Basically, you determine the length of the whole real string and then $repeat() a number of space characters in which you take the total position of the `|` and $sub() the length.

Here is a (German) thread that centers text:

> [@Frage zur Exportfunktion: %Album% mittig ausgeben](https://community.mp3tag.de/t/frage-zur-exportfunktion-album-mittig-ausgeben/15308):
>
> Hallo ich hab noch einmal eine Frage zur Exportfunktion ich möchte den Namen eines Albums (%album%) automatisch mittig in einem Überschrift-Rahmen plazieren. Die Rahmenbreite ist fest vorgegebne (z.B. 65 Zeichen) etwa so: ================================================================================ =..................................mein Album..................................= ================================================================================ (die Punkte links und rech…

The code should be readable, though

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 21, 2025, 7:27am UTC](https://community.mp3tag.de/t/how-to-remove-whitespace-right-to-a-string-based-on-its-length/67234/3 "2025-02-21T07:27:58Z")

</div>

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