# Replace repeated characters with single instance of character

**URL:** https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486
**Category:** Support
**Created:** [January 19, 2024, 5:48pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486 "2024-01-19T17:48:48Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![girw1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@girw1](https://community.mp3tag.de/u/girw1)
#### Post date: [January 19, 2024, 5:48pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/1 "2024-01-19T17:48:48Z")

</div>

Hello

I use this wonderfull program to organize my music collection for years now.  
However i finaly encounterd a problem that my google fu cant solve:

Situation: The shitty stereo in my new used car can only play mp3s and cannot read any tags the only thing it can display is the file name of max 8 symbols.  
Thus i want to give each file a name according to a simple identification system . In order to accomplish this i add 2 tags to my flac files:  
artistcodon - a 3 letter abreviation of the artist  
titlecodon - a 5 letter abbreviation of the title  
which i can use to tell foobar to make some tagless mp3s and name them %artistcodon%%titlecodon%.mp3

It was pretty easy to export a list of artistnames, manualy assign each a 3 letter code and format the list into an ifartisthenthiscode action group in notepad++  
However im not going to manualy assign title codes to thousands of files. therefore i came up with this adequate solution:  
copy title - get rid of all non letters/numbers - remove some small words (the, a, der, die (maybe i should find out if the german or the english word exists more often in my collection...), das, el, il, of, etc.) - upper case - remove spaces - replace any nonascii unicode character with single ascii char - remove all sequences of: the same letter repeated - if it is longer than 5 letters remove vowels (OEUIA in that order, it is as good as any other. and repeat the double letter removal in between each) - pad the result with 00000 at the end - cut it to 5 chars.  
That should give me somewhat readable filenames, mostly without conflicts.

The problem:  
How do i replace repeated chars with a single instance of said char? (so for example: ttt \> t, mm \> m)

i tried replace with regex:  
find .{2,}  
replace .  
but that doesnt work at all.

---

<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 19, 2024, 6:24pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/2 "2024-01-19T18:24:59Z")

</div>

> [@girw1](#):
>
> Situation: The shitty stereo in my new used car can only play mp3s and cannot read any tags the only thing it can display is the file name of max 8 symbols.

Have you tried to use V1 tags (instead of V2.x)

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 19, 2024, 6:26pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/3 "2024-01-19T18:26:01Z")

</div>

A possible regular expression would look like this  
`(.)\1{1,}`  
and the substitution / replacement would be  
`$1`

If you would like to reduce repeated characters in the tag TITLE it would look like this  
TITLE  
`$regexp(%TITLE%,'(.)\1{1,}',$1)`  
 ![image](https://community.mp3tag.de/uploads/default/original/3X/7/9/791f227ebbb2c5aca1158b392bc077919fef5cb4.png)

---

<div class="post-metadata">

### Author: ![girw1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@girw1](https://community.mp3tag.de/u/girw1)
#### Post date: [January 19, 2024, 6:26pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/4 "2024-01-19T18:26:41Z")

</div>

Even the manual of the car stereo says that it can only display the filename.

---

<div class="post-metadata">

### Author: ![girw1](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@girw1](https://community.mp3tag.de/u/girw1)
#### Post date: [January 19, 2024, 6:28pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/5 "2024-01-19T18:28:51Z")

</div>

## Thanks That worked!

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 19, 2024, 6:28pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/6 "2024-01-19T18:28:57Z")

</div>

This also works for the `_FILENAME`:

![image](https://community.mp3tag.de/uploads/default/original/3X/8/b/8b8696b4a80a56c9e5ccf4ead835f9de33cf9d36.png)

---

<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 20, 2024, 2:44pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/7 "2024-01-20T14:44:55Z")

</div>

A post was split to a new topic: [Remove vowels in string from position 4 onwards](https://community.mp3tag.de/t/remove-vowels-in-string-from-position-4-onwards/63497)

---

<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 19, 2024, 2:45pm UTC](https://community.mp3tag.de/t/replace-repeated-characters-with-single-instance-of-character/63486/8 "2024-02-19T14:45:28Z")

</div>

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