"Tag - Filename" creates a directory when artist name contains certain characters

Artist: C\/\/\/\
Title: Blah

Bug: On Tag - Filename using %artist% - %title%, the file is not renamed as expected. Instead, a directory is created named C with the file moved into it named - Blah.flac.

Expected: File should be renamed, and not moved into a new directory. Mp3tag should compensate by omitting these invalid filename characters. It would be nice to be able to customize this behavior and choose to either omit invalid characters (current), or replace them with a character of choice (such as _). So in this scenario, the resultant file should either be C - Blah.ext or (with requested feature) C_______ - Blah.flac.


Mp3tag v3.02 (at least present since ~v3.00, possibly earlier)
Windows 10 v2004

The characters that you list are no invalid characters - as opposed to ?* and some more..

Also see a similar description here where your observation was rated as "no bug":

Thanks for the solution. I guess I should replace all my references to %artist% to $replace(%artist%,,).

It does strike me as odd that Mp3tag wouldn't handle this by default, but rather require you to first encounter this scenario and then find a way to overcome it. Writing a title should always work in my opinion, and any advanced features (using \ for directory creation I assume) should be what requires searching online for, not for writing tags accurately. Just my opinion.

Windows reports \ / : * ? " < > | as invalid characters, but I assume you mean in Mp3tag's logic.


Or replace the slash with something that looks like a slash but isn't.
This may also avoid problems with some players that take the slash as in-field separator to create 2 entries out of one so that e.g. "AC/DC" becomes the artists "AC" and "DC".
e.g. AC⁄DC stays just one name.

I'm looking for a global solution that I don't have to think about on a per-release basis. Maybe $validate(…) will help too.

I assume $replace(%dummy%,,) replaces Mp3tag's list of invalid characters / ? * " < > | : including \?

as I said: the / and \ are valid characters in filenames and help to create folder structures from tags, see the FAQs:

So $validate() will not remove these 2 characters.

Thank you very much for the help. I think I should be able to find a solution out of the links you've provided.

I've tried adding a custom playlist filename to mirror the names of my directories but it doesn't seem to be possible:

Album name: Album \/?*"<>|:.

$replace(%album%,\,_,/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_).m3u8 gives: "Playlist - Filename: Following characters are not allowed in file names: \\ / : * ? " < > |".

What works is $replace(%album%,\,_).m3u8 however all other symbols will then be replaced by nothing (which isn't what I would like in this case).

Since $replace(…) is going to…replace those symbols, it seems like a logic error in the program's code to not allow this. Wouldn't be the first time I'm wrong though.


I am not sure what you do but
gives: _________.
which looks ok to me.

In Mp3tag Options > Playlist > Filename of playlist is where the formatting doesn't work.

I just tried
which replace the "e" with an "x" and the result is:
c:\temp\Ambixnt Diary.Two_28.07.2020 160630.m3u8

Yes, using $replace() is allowed and works there, but not using the symbols / ? * " < > | : anywhere in the string. Even though $replace() would replace those symbols, Mp3tag doesn't allow them in the string I think. I cannot see a way around this. I will have to do this manually then.

I cannot very that - even though apparently one has to tweak it a little bit:
String in options:
c:\temp\$replace(%album%_%_datetime%/ ? * " < > | :,e,x,"/",_,"?",_,"*",_,",_,<,_,>,_,|,_,:,_,\,_).m3u8
Result: c:\temp\Ambixnt Diary.Two_28.07.2020 16_24_20 _ _ _ _ _.m3u8

That does seem to work. Unfortunately, it only works when an absolute path is specified. %_folderpath% cannot be used in c:\temp\'s place. It also seems necessary for \,_ to be last in the $replace() string.

My current string is (which doesn't work, but will give you an idea of my goal):
$replace([$left(%year%,4) - ][%album%],/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_,\,_).m3u8

I just would like to make sure any invalid characters for Windows filenames are converted to _.

Since I cannot get this to work, for consistency's sake, I've just settled on omitting any invalid characters instead. So all I need is $replace(blah,\,) and Mp3tag will handle omitting the rest of the invalid filename characters.

Thanks for the help @ohrenkino!

%_folderpath% is an absolute path ...

YEAR should actually never be longer than 4 digits.
For more exact dates there is RELEASETIME.

That string works over here - or at least I get an underscore where I added a backslash in the album name.