# Convert filename with replace

**URL:** <https://community.mp3tag.de/t/convert-filename-with-replace/51446>\
**Category:** Support\
**Created:** [January 3, 2021, 9:38am UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446 "2021-01-03T09:38:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![caffca](https://community.mp3tag.de/user_avatar/community.mp3tag.de/caffca/32/8638_2.png) [@caffca](https://community.mp3tag.de/u/caffca)\
**Post date:** [January 3, 2021, 9:38am UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/1 "2021-01-03T09:38:06Z")

</div>

Good morning,

i need some help for this:

- My original tag formatting

**Artist:** TRIUMVIRAT  
**Title:** e minor 5/9 minor /5: broken / head over heels / broken

- file name required after conversion Tag ---\> Filename

**required file name:** TRIUMVIRAT-e minor 5\_9 minor\_5: broken\_head over heels\_broken

**name of the file that appears:** e minor 59 minor 5 broken head over heels broken

I tried: `%artist%-$replace(%Title%,': ','_','/','_'' / ','_')` _but there are some problems with the spaces_

Thank you for your help

---

<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:** [January 3, 2021, 11:23am UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/2 "2021-01-03T11:23:21Z")

</div>

Can you edit your post to enclose the format string in backticks ```, e.g., ``my format string`` so that spaces and other special characters are preserved?

---

<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 3, 2021, 12:52pm UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/3 "2021-01-03T12:52:58Z")

</div>

> [@caffca](#):
>
> **required file name:** TRIUMVIRAT-e minor 5\_9 minor\_5: broken\_head over heels\_broken

I doubt that this filename will work in Windows. AFAIK the colon is not allowed as part of the filename but only to define the drive letter.  
Did you have a look at the function $validate()? It looks to me as though you want to replace any illegal character with an underscore. This could be achieved with  
`$validate(%title%,_)`  
and in respect to the $replace() function: you have to define pairs, e.g. if you want to replace the ": " with "\_" and " /" with `_` the syntax would be `replace(%Title%,: ,_, /,_)`.  
I your code example I think there is at least one incomplete pair and it also looks to me as though you defined a list of characters and then put the resulting character last.

---

<div class="post-metadata">

**Author:** ![caffca](https://community.mp3tag.de/user_avatar/community.mp3tag.de/caffca/32/8638_2.png) [@caffca](https://community.mp3tag.de/u/caffca)\
**Post date:** [January 4, 2021, 12:07pm UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/4 "2021-01-04T12:07:08Z")

</div>

Good morning,

Thanks for your quick response and successful solution.

The format: **$validate(%artist%-%title%,\_)** is the best solution.

My best regards

caffca

---

<div class="post-metadata">

**Author:** ![caffca](https://community.mp3tag.de/user_avatar/community.mp3tag.de/caffca/32/8638_2.png) [@caffca](https://community.mp3tag.de/u/caffca)\
**Post date:** [January 4, 2021, 12:38pm UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/5 "2021-01-04T12:38:08Z")

</div>

It also works using the **$replace format**

**`$replace(%artist%-%title%,:,_, / ,_,/,_,)`**

Artist-Title: JAMIE ISAAC-(4:30) idler / sleep -\>  
Filename: JAMIE ISAAC-(4\_30) idler\_sleep.mp3

Artist-Title: RÖYKSOPP-40 years back / come -\>  
Filename: RÖYKSOPP-40 years back\_come.mp3

Artist-Title: STING & SHAGGY-44876.mp3 -\>  
Filename: STING & SHAGGY-44\_876.mp3

Thanks again

caffca

---

<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 3, 2021, 12:38pm UTC](https://community.mp3tag.de/t/convert-filename-with-replace/51446/6 "2021-02-03T12:38:19Z")

</div>

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