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

**URL:** https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762
**Category:** Support
**Created:** [July 28, 2020, 12:00pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762 "2020-07-28T12:00:22Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 12:00pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/1 "2020-07-28T12:00:22Z")

</div>

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`.

Thanks.

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

---

<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: [July 28, 2020, 12:15pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/2 "2020-07-28T12:15:31Z")

</div>

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":

> [@\[X\] Renaming from tags with "\\" character creates a new folder!](https://community.mp3tag.de/t/x-renaming-from-tags-with-character-creates-a-new-folder/6166):
>
> As I said in the title: Renaming from tags with "" character creates a new folder! (wtf?) Maybe you won't consider this as a bug, but think of it! Are you sure the user pretends to create a new folder when he is just remaming his files from the title? I think not, and it's not so strange to find song titles with rare characters like that. What it should do is just skip those characters when renaming, or at least give you that option, wich would be still better, but of course the default opt…

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 12:29pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/3 "2020-07-28T12:29:59Z")

</div>

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.

Thanks.

---

<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: [July 28, 2020, 12:40pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/4 "2020-07-28T12:40:49Z")

</div>

> [@mr\_bug](#):
>
> I guess I should replace all my references to `%artist%` to `$replace(%artist%,,)` .

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.

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 12:51pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/5 "2020-07-28T12:51:32Z")

</div>

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 `\`?

---

<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: [July 28, 2020, 12:56pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/6 "2020-07-28T12:56:14Z")

</div>

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

> [@Converters to rename files or to import tags](https://community.mp3tag.de/t/converters-to-rename-files-or-to-import-tags/8016/2):
>
> How to rename files based on tags? Renaming files, creating folders and complete directory structures from tags can be done by using the [:mt\_ttf:] Converter \> Tag - Filename with a format string. A format string is used to describe the structure of the desired filename. Besides using normal placeholders (such as %artist%, %title%, ...) and arbitrary text (e.g., Music) it also allows for separating folders with the backslash \ character. Here is an example that renames the file based on the t…

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

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 1:11pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/7 "2020-07-28T13:11:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 1:53pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/8 "2020-07-28T13:53:36Z")

</div>

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.

Thanks.

---

<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: [July 28, 2020, 2:01pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/9 "2020-07-28T14:01:54Z")

</div>

I am not sure what you do but  
`$replace(\/?*"<>|:.,\,_,/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_)`  
gives: ` _________.`  
which looks ok to me.

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 2:03pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/10 "2020-07-28T14:03:16Z")

</div>

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

---

<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: [July 28, 2020, 2:08pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/11 "2020-07-28T14:08:28Z")

</div>

I just tried  
`c:\temp\$replace(%album%_%_datetime%,e,x).m3u8`  
which replace the "e" with an "x" and the result is:  
`c:\temp\Ambixnt Diary.Two_28.07.2020 160630.m3u8`

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 2:13pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/12 "2020-07-28T14:13:44Z")

</div>

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.

---

<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: [July 28, 2020, 2:26pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/13 "2020-07-28T14:26:07Z")

</div>

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`

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 3:12pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/14 "2020-07-28T15:12:17Z")

</div>

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 `_`.

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [July 28, 2020, 3:57pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/15 "2020-07-28T15:57:27Z")

</div>

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!

---

<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: [July 28, 2020, 5:07pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/16 "2020-07-28T17:07:25Z")

</div>

> [@mr\_bug](#):
>
> Unfortunately, it only works when an absolute path is specified. `%_folderpath%` cannot be used in `c:\temp\` 's place

%\_folderpath% is an absolute path ...

> [@mr\_bug](#):
>
> $left(%year%,4)

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

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

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

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [August 27, 2020, 8:57pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/17 "2020-08-27T20:57:38Z")

</div>

> [@ohrenkino](#):
>
> %\_folderpath% is an absolute path ...

Using `%_folderpath%` will change:  
`c:\temp\$replace(%album%,"/",_,"?",_,"*",_,",_,<,_,>,_,|,_,:,_,\,_).m3u8`  
to (after automatic correction):  
`%_folderpath%\$replace(%album%,,_,,_,,_,,_,,_,,_,,_,,_,\,_).m3u8`.  
So even though `%_folderpath` is an absolute path, I can't get it to work here.

Edit: Interestingly, adding `\\` to the start of `\\%_folderpath%\$replace(%album%,/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_,\,_).m3u8` at least allows me to OK the string without Mp3tag complaining, but when I try to write a playlist file, it shows `\\C\Users\my_user\Desktop\New folder\ _________.m3u8`. If you notice, `C\` is missing `:`. Not sure what's up with that.

> [@ohrenkino](#):
>
> > [@mr\_bug](#):
> >
> > `$replace([$left(%year%,4) -][%album%],/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_,\,_).m3u8`
> 
> That string works over here - or at least I get an underscore where I added a backslash in the album name

I'm not sure how it works for you; when I try to use that string, Mp3tag complains that the "Following characters are not allowed in file names: \ / : \* ? " \< \> |" and wants to apply an automatic correction. After I apply it, the `$replace` is again all underscores (like above).

All I want is an album name of `\/?*"<>|:` to be replaced by nine underscores ` _________ ` when creating a m3u8 playlist file. I just can't figure it out.

> [@ohrenkino](#):
>
> YEAR should actually never be longer than 4 digits.  
> For more exact dates there is RELEASETIME.

Assuming ID3v2.4, [ID3 wiki](https://en.wikipedia.org/wiki/ID3#endnote_TYER):

> TDRC (recording time) consolidates [v2.3's] TDAT (date), TIME (time), TRDA (recording dates), and TYER (year)

id3v2.4.0-frames.txt [4.2.5](https://id3.org/id3v2.4.0-frames#line-584):

> TDRC The 'Recording time' frame contains a timestamp describing when the audio was recorded. timestamp format is described in the ID3v2 structure document [ID3v2-strct].

id3v2.4.0-structure.txt [4](https://id3.org/id3v2.4.0-structure#line-377):

> … valid timestamps are yyyy, yyyy-MM, yyyy-MM-dd, yyyy-MM-ddTHH, yyyy-MM-ddTHH:mm and yyyy-MM-ddTHH:mm:ss.

… so it seems dates longer than just `yyyy` are fine.

I in fact don't use `YEAR` as it's mapped to `DATE` (`DATE` being a VorbisComment field which I like to use). If I was using ID3's convention, `RELEASETIME` does indeed seem to be the more accurate field to use for such info though.

---

<div class="post-metadata">

### Author: ![mr\_bug](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mr\_bug](https://community.mp3tag.de/u/mr_bug)
#### Post date: [August 27, 2020, 11:00pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/18 "2020-08-27T23:00:02Z")

</div>

I think I've finally found the solution! And kind of by luck:

`\\\\$replace(%album%,/,_,?,_,*,_,",_,<,_,>,_,|,_,:,_,\,_).m3u8`.

For some reason, `\\\\` was all that was needed to escape(?) whatever magic was happening in the background.

Playlists now created give `C:\Users\my_user\Desktop\New folder\ _________.m3u8`.

Perfect!

---

<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: [September 26, 2020, 11:00pm UTC](https://community.mp3tag.de/t/tag-filename-creates-a-directory-when-artist-name-contains-certain-characters/49762/19 "2020-09-26T23:00:06Z")

</div>

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