# Use multiple $replace string

**URL:** https://community.mp3tag.de/t/use-multiple-replace-string/19069
**Category:** General Discussion
**Created:** [June 22, 2017, 6:03am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069 "2017-06-22T06:03:05Z")
**Posts on this page:** 8
**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 22, 2017, 6:03am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/1 "2017-06-22T06:03:05Z")

</div>

Hi Guys

Just joined and are very new to this scripting thing. And english arent my main, so I don't know what to google - I have tried.

I am generating a .nfo file with export.

1. This is the line in the top:  
$filename($replace(%artist%, ,_,) - $replace(%album%, ,_).nfo,ansi)

The $replace 'space with \_' is just fine. But I have multiple replacements I want to use (Trying to name after scene rules).

But how do I $replace with multiple string? Cause let's say that the album name is "Name & Name", then I want to place space with \_ (Which I did), but I also want to place '&' with 'Og' etc etc.

Can someone please help me out, and explain it in details. 🙂

---

<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 22, 2017, 6:09am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/2 "2017-06-22T06:09:22Z")

</div>

> [@MusicBits](#):
>
> ...  
> $filename($replace(%artist%, ,_,) - $replace(%album%, ,_).nfo,ansi)  
> ...but I also want to place '&' with 'Og' etc etc.
> 
> Can someone please help me out, and explain it in details. 🙂

You can include several pairs for replacement in one statement, e.g.  
$replace(%artist%, ,\_,&,Og,water,wine,evil,good)  
you would have to use a separate function call if the field is a different one.

---

<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 22, 2017, 6:16am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/3 "2017-06-22T06:16:48Z")

</div>

> [@ohrenkino](#):
>
> You can include several pairs for replacement in one statement, e.g.  
> $replace(%artist%, ,\_,&,Og,water,wine,evil,good)  
> you would have to use a separate function call if the field is a different one.

Wow, that was too simple. Thank you very much for a quick reply! 🙂

Could you by any chance explain separate function call?

---

<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 22, 2017, 6:21am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/4 "2017-06-22T06:21:28Z")

</div>

Oki, seems I have already run into trouble.

It worked fine when I added ,&,Og,

But when I added ,',, because I want to remove ' from the file name, it didnt work:

$filename($replace(%artist%, ,_,&,Og,',,)-$replace(%album%, ,_,&,Og,',,).nfo,ansi)

Any suggestions?

---

<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 22, 2017, 6:24am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/5 "2017-06-22T06:24:13Z")

</div>

> [@MusicBits](#):
>
> ...  
> Any suggestions?

see the help?  
[https://docs.mp3tag.de/scripting](https://docs.mp3tag.de/scripting)

"... ' Outputs raw text without parsing. This will output the contained string and ignore all reserved characters. If you want to output this character, please use ''. ...."

---

<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 22, 2017, 6:27am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/6 "2017-06-22T06:27:54Z")

</div>

> [@ohrenkino](#):
>
> see the help?  
> [https://docs.mp3tag.de/scripting](https://docs.mp3tag.de/scripting)
> 
> "... ' Outputs raw text without parsing. This will output the contained string and ignore all reserved characters. If you want to output this character, please use ''. ...."

I am sorry. I have looked in help all day. But me and code are not getting along. It's like reading chinese. :-/

Thank you again. Found out now.  
$filename($replace(%artist%, ,_,&,Og,'',,)-$replace(%album%, ,_,&,Og,'',,).nfo,ansi)

---

<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 22, 2017, 6:32am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/7 "2017-06-22T06:32:20Z")

</div>

> [@MusicBits](#):
>
> I am sorry. I have looked in help all day. But me and code are not getting along. It's like reading chinese. :-/

Use the ' twice '' to get one '

---

<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: [June 22, 2017, 10:20am UTC](https://community.mp3tag.de/t/use-multiple-replace-string/19069/8 "2017-06-22T10:20:22Z")

</div>

> [@MusicBits](#):
>
> ... But me and code are not getting along. It's like reading chinese. ... $filename($replace(%artist%, ,_,&,Og,'',,)-$replace(%album%, ,_,&,Og,'',,).nfo,ansi)

If you are unsure about the special characters "Apostrophe" and "Double Quote", you may apply them as the result of the Mp3tag $char() function:  
$char(32) gives the space character,  
$char(34) gives the double quote character,  
$char(38) gives the ampersand character,  
$char(39) gives the single apostrophe character.  
(see also: [https://en.wikipedia.org/wiki/ASCII)](https://en.wikipedia.org/wiki/ASCII))

$filename($replace(%artist%, ,\_,&,Og,'',,)-$replace(%album%, ,\_,&,Og,'',,).nfo,ansi)

$filename($replace(%artist%'-'%album%'.nfo',$char(32),$char(95),$char(38),'Og',$char(39),$char(0)),ansi)

 

DD.20170622.1425.CEST
