# Tag to filename, replacing invalid characters with user specified ones

**URL:** https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835
**Category:** General Discussion
**Created:** [September 3, 2012, 4:18pm UTC](https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835 "2012-09-03T16:18:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 3, 2012, 4:18pm UTC](https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835/1 "2012-09-03T16:18:58Z")

</div>

Is this possible to set in the ![:mt_ttf:](https://community.mp3tag.de/uploads/default/original/1X/922db76db5d45b2e558d10f3d8c25fb8bc04fd27.png ":mt\_ttf:") "Tag to Filename" dialogue, or do I have to write an action to do it?

By default Mp3tag deletes all Windows invalid characters (\ / : \* ? " \< \> |) when doing this.

---

<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: [September 3, 2012, 5:49pm UTC](https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835/2 "2012-09-03T17:49:15Z")

</div>

You can append the mask with the scripting command $validate.  
You can specify a replacement character in this command.  
You can define a separate validation for each part of the mask.  
E.g.: $validate(%artist% - %title%,_) validates the whole mask.  
$validate(%artist%,-) - $validate(%title%,_)  
defines a hyphen for ARTIST and an uderscore for TITLE.

---

<div class="post-metadata">

### Author: ![aax](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@aax](https://community.mp3tag.de/u/aax)
#### Post date: [September 3, 2012, 11:02pm UTC](https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835/3 "2012-09-03T23:02:34Z")

</div>

Thanks, but **$validate** seems to replace all invalid characters with the same character, not each one with a specific character that I choose.

I've found out that I can use **$replace(string,from,to)** from the predefined functions in the ![:mt_ttf:](https://community.mp3tag.de/uploads/default/original/1X/922db76db5d45b2e558d10f3d8c25fb8bc04fd27.png ":mt\_ttf:") dialogue, which would then do this for example:

$replace(%track%,\*,+) would replace all \* in the track title with +

also, I can continue adding **from,to** pairs in the same bracket and it will replace all the characters I choose, like this:

_Title tag:_  
Titoli di Testa: "Canzonetta" / Notturno II [\*]

_Tag to filename format string:_  
$num(%track%,2) $replace(%title%,\*,+,/,-,:, -,",'') the last thing in the brackets are 2 apostrophes

_Resulting filename:_  
01 Titoli di Testa - 'Canzonetta' - Notturno II [+]

Is this a proper thing to use in Tag - Filename dialogue?

---

<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: [September 4, 2012, 3:55am UTC](https://community.mp3tag.de/t/tag-to-filename-replacing-invalid-characters-with-user-specified-ones/13835/4 "2012-09-04T03:55:39Z")

</div>

> [@aax](#):
>
> ... **$validate** seems to replace all invalid characters with the same character, not each one with a specific character that I choose. ... Is this a proper thing to use in Tag - Filename dialogue?

See also ...  
[Renaming files with tag, replace trailing periods](https://community.mp3tag.de/t/12740/6)

DD.20120904.0755.CEST
