# File name to tag with complicated folder structure

**URL:** <https://community.mp3tag.de/t/file-name-to-tag-with-complicated-folder-structure/44126>\
**Category:** Support\
**Created:** [January 6, 2019, 10:49pm UTC](https://community.mp3tag.de/t/file-name-to-tag-with-complicated-folder-structure/44126 "2019-01-06T22:49:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JerryB](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/ccd318/32.png) [@JerryB](https://community.mp3tag.de/u/JerryB)\
**Post date:** [January 6, 2019, 10:49pm UTC](https://community.mp3tag.de/t/file-name-to-tag-with-complicated-folder-structure/44126/1 "2019-01-06T22:49:58Z")

</div>

I'ld like to rewrite the tags of all my songs cause some of them seem to be really messed up.

My music is organized in folders. Mostly:  
\Genre\Artist\Year - Album\Track# - Title  
That converts easily to the corresponding tag infos.

However if the album consists of more than one CD the folder structure turns to:  
\Genre\Artist\Year - Album\CDn\Track# - Title  
(where CDn means the nth CD of that particular album)

Is there a way to rewrite the tags in one batch without filtering the two possibilities mentioned above beforehand?

I tried $if to no avail. Probably my stupidity. Thanks in advance for any hints!

---

<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 7, 2019, 6:37am UTC](https://community.mp3tag.de/t/file-name-to-tag-with-complicated-folder-structure/44126/2 "2019-01-07T06:37:36Z")

</div>

You could try it with an action group with 2 actions:  
**Guess values**  
Source: **%\_filename%**  
Format string: `%Genre%\%Artist%\%Year% - %Album%\%Track% - %Title%`

**Guess values**  
Source: **%\_filename%**  
Format string: `%Genre%\%Artist%\%Year% - %Album%\CD%discnumber%\%Track% - %Title%`

The first action always fills tags which is correct for albums without further CDs.  
The second action only applies if there is a CD and will then overwrite the already imported data but only if the pattern matches. So albums without further CDs are left alone.  
To be sure, I would use an absolute path.

And another thing:

> [@JerryB](#):
>
> I'ld like to rewrite the tags of all my songs cause some of them seem to be really messed up.

Please note that the filename is not a very good backup storage for metadata. There are a number of invalid characters for filenames in the various names and titles.(e.g. ? \* \> \< /\ - so "A\*Teens" would be messed up just like Axwell /\ Ingrosso or AC/DC, the track "What have I done to deserve this?" would appear without the "?" and so on)  
So if you have these characters already in your tags then do not overwrite them with the data from the filenames as you would loose these characters.

---

<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 9, 2026, 12:27pm UTC](https://community.mp3tag.de/t/file-name-to-tag-with-complicated-folder-structure/44126/3 "2026-02-09T12:27:51Z")

</div>


