# Problem with replace ()\[\]

**URL:** https://community.mp3tag.de/t/problem-with-replace/19093
**Category:** General Discussion
**Created:** [June 26, 2017, 10:32am UTC](https://community.mp3tag.de/t/problem-with-replace/19093 "2017-06-26T10:32:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![MusicBits](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@MusicBits](https://community.mp3tag.de/u/MusicBits)
#### Post date: [June 26, 2017, 10:32am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/1 "2017-06-26T10:32:16Z")

</div>

Hi guys

I use this line when I rename a folder in MP3tag:  
$replace(%artist%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,é,e,'',,´,,!,,)-$replace(%album%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'(',,')',,é,e,´,,!,,',',,)

I want to replace ()[] in album or artistname, but the problem is, if the Albumname or artistname for instance is:

Albumname Albumname (Someting)  
Artistname Artistname (Something)

It will change to:  
Albumname\_Albumname\_-_Something  
Artistname\_Artistname_-\_Something

because I am already replacing space with \_ and () with nothing.

How can I get it to look like this instead:

Albumname\_Artistname-Something  
Artistname\_Artistname-Something

Hope it make sense.

---

<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: [June 26, 2017, 10:44am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/2 "2017-06-26T10:44:53Z")

</div>

> [@MusicBits](#):
>
> Hi guys
> 
> I use this line when I rename a folder in MP3tag:  
> $replace(%artist%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,é,e,'',,´,,!,,)-$replace(%album%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'(',,')',,é,e,´,,!,,',',,)
> 
> I want to replace () in album or artistname, but the problem is, if the Albumname or artistname for instance is:
> 
> Albumname Albumname (Someting)  
> Artistname Artistname (Something)
> 
> It will change to:  
> Albumname\_Albumname\_-_Something  
> Artistname\_Artistname_-\_Something  
> ...  
> Hope it make sense.

The $replace() expression has no "-" anywhere in it so that the result would never be "-" as replacement for e.g. a "("

The function  
$replace('Albumname Albumname (Someting)', ,\_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'(',,')',,é,e,´,,!,,',',,)

leads to the result "Albumname\_Albumname\_Someting"  
so your example string does not match, neither source nor result nor replace-string...

Can you do it again?

PS: you can test the outcome with the function Convert\>Tag-Tag and an example string.

---

<div class="post-metadata">

### Author: ![MusicBits](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@MusicBits](https://community.mp3tag.de/u/MusicBits)
#### Post date: [June 26, 2017, 10:56am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/3 "2017-06-26T10:56:35Z")

</div>

> [@ohrenkino](#):
>
> The $replace() expression has no "-" anywhere in it so that the result would never be "-" as replacement for e.g. a "("
> 
> The function  
> $replace('Albumname Albumname (Someting)', ,\_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'(',,')',,é,e,´,,!,,',',,)
> 
> leads to the result "Albumname\_Albumname\_Someting"  
> so your example string does not match, neither source nor result nor replace-string...
> 
> Can you do it again?
> 
> PS: you can test the outcome with the function Convert\>Tag-Tag and an example string.

Actually (Just tested) the output from this:

Artist: New Politics  
Album: Vikings (Test)

Becomes: New\_Politics-Vikings\_Test

I want it to be: New\_Politics-Vikings-Test

---

<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: [June 26, 2017, 10:58am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/4 "2017-06-26T10:58:29Z")

</div>

> [@MusicBits](#):
>
> Actually (Just tested) the output from this:
> 
> Artist: New Politics  
> Album: Vikings (Test)
> 
> Becomes: New\_Politics-Vikings\_Test
> 
> I want it to be: New\_Politics-Vikings-Test

But then the replacement rule for the "(" is not correct. It should be:  
' (',-

---

<div class="post-metadata">

### Author: ![MusicBits](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@MusicBits](https://community.mp3tag.de/u/MusicBits)
#### Post date: [June 26, 2017, 11:04am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/5 "2017-06-26T11:04:55Z")

</div>

> [@ohrenkino](#):
>
> But then the replacement rule for the "(" is not correct. It should be:  
> ' (',-

And then you will get:

New\_Politics-Vikings\_-Test

Because the blank space is also replaced with \_ and you can't remove that.

---

<div class="post-metadata">

### Author: ![MusicBits](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@MusicBits](https://community.mp3tag.de/u/MusicBits)
#### Post date: [June 26, 2017, 11:24am UTC](https://community.mp3tag.de/t/problem-with-replace/19093/6 "2017-06-26T11:24:17Z")

</div>

> [@MusicBits](#):
>
> And then you will get:
> 
> New\_Politics-Vikings\_-Test
> 
> Because the blank space is also replaced with \_ and you can't remove that.

Found the solution. I did not know that is was a chain reaction.

So this did the trick:  
$replace(%artist%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'_(',-,')',,é,e,´,,!,,',',,)-$replace(%album%, ,_,&,Og,Æ,Ae,æ,ae,Å,Aa,å,aa,Ø,Oe,ø,oe,'',,'_(',-,')',,é,e,´,,!,,',',,)-%SOURCE%-%\_tag%-%year%-MusicBits
