How to Replace Illegal Characters Upon Writing Tags to Filename

Hi Everybody,

I have scoured the Mp3tag Scripting Functions, but cannot get this right: I want to replace the "illegal" Windows characters such as (:, ", ?, /, *, |) and so forth, with any character of my own choosing, not just blank spaces. Can someone please help me with a script do just that? Also, how do I set it up so that every time Mp3tag writes the tag to filename, the illegal characters are replaced with my own?

Thanks for your assistance.

PS. I want to retain the "illegal" characters in the metadata.

Look here under "Remove invalid characters from file name/file paths".

In Mp3tag go to Convert > Tag - Filename and use the $validate command in the format string.

Thanks, I saw that, but did not know how to apply it.

On second look, I've got it. :slight_smile:

This is the one I use $validate(%artist% - %track% - %title%,_)

It replaces invalid characters with an underscore _.

Edit: Ok, I just saw your edit.

Thanks again, stanman. I have to learn to read more carefully. Sorry for the bother.

Command: $replace(string,from,to) or $replace(string,from1,to1,from2,to2,...)
Example: $replace(%artist% - %album% - %track% - %title%,_,-)
This example replaces all underscores with dashes. You can provide additional pairs of from/to as parameters.