# Set Genre to root folder name

**URL:** <https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890>\
**Category:** Support\
**Created:** [May 7, 2015, 2:20pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890 "2015-05-07T14:20:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![boomklever](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@boomklever](https://community.mp3tag.de/u/boomklever)\
**Post date:** [May 7, 2015, 2:20pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890/1 "2015-05-07T14:20:13Z")

</div>

Sorry for being a newbie. And I did try to find a solution in the forum, but I did not succeed.

Here's my (simple) problem:

My music folder structure is like

s:\acoustic guitar\artist1\album1  
s:\acoustic guitar\artist1\album2  
s:\pop\artist2\album1  
s:\pop\artist3\album1\disc1  
s:\pop\artist3\album1\disc2

etc

Now I want to assign the root folder name to the Genre tag. So "acoustic guitar" and "pop" in this example. I already have the full path assigned to the Genre tag. I probably have to use expressions to strip "s:" from the Genre string and all the characters past the second "". But how do I do that?

Really appreciate MP3TAG, very powerfull...

---

<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:** [May 7, 2015, 2:52pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890/2 "2015-05-07T14:52:24Z")

</div>

> [@Jan van Veen](#):
>
> ... I want to assign the root folder name to the Genre tag. ...

There are several methods to reach the goal ...  
by using the Mp3tag scripting language ...  
here is one proposal from the bag of tricks ...

Apply a group of two actions ...

 **Action 1: Format value Field: GENRE Formatstring: $replace(%\_path%,'\','\\\\') Action 2: Format value Field: GENRE Formatstring: $meta(GENRE,1)**

... or ...  
apply one action ...

 **Action 1: Format value Field: GENRE Formatstring: $regexp(%\_path%,'^.+?\\\\(.+?)\\\\.\*$','$1')**

... or ...  
apply one action ...

 **Action 1: Format value Field: GENRE Formatstring: $left($cutLeft(%\_path%,$strchr(%\_path%,'\')),$sub($strchr($cutLeft(%\_path%,$strchr(%\_path%,'\')),'\'),1))**

... or ...  
apply a group of four actions ...

**Action 1: Format value Field: GENRE Formatstring: %\_path% Action 2: Format value Field: GENRE Formatstring: $cutLeft(%GENRE%,$strchr(%GENRE%,'\')) Action 3: Format value Field: GENRE Formatstring: $left(%GENRE%,$strchr(%GENRE%,'\')) Action 4: Format value Field: GENRE Formatstring: $trimRight(%GENRE%,'\')**

DD.20150507.1852.CEST, DD.20150507.2002.CEST

---

<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:** [May 7, 2015, 2:56pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890/3 "2015-05-07T14:56:36Z")

</div>

> [@Jan van Veen](#):
>
> Sorry for being a newbie. And I did try to find a solution in the forum, but I did not succeed.
> 
> Here's my (simple) problem:
> 
> My music folder structure is like
> 
> s:\acoustic guitar\artist1\album1  
> s:\acoustic guitar\artist1\album2  
> s:\pop\artist2\album1  
> s:\pop\artist3\album1\disc1  
> s:\pop\artist3\album1\disc2  
> ...

Perhaps you assign the genre part of the filename again and leave out the stripping.  
Use the function Convert\>Filename-Tag  
Format string: %genre%\%dummy%\%dummy%

---

<div class="post-metadata">

**Author:** ![boomklever](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/5fc32e/32.png) [@boomklever](https://community.mp3tag.de/u/boomklever)\
**Post date:** [May 7, 2015, 5:20pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890/4 "2015-05-07T17:20:40Z")

</div>

> [@DetlevD](#):
>
> There are several methods to reach the goal ...  
> by using the Mp3tag scripting language ...  
> here is one proposal from the bag of tricks ...
> 
> Apply a group of two actions ...
> 
> **Action 1: Format value Field: GENRE Formatstring: $replace(%\_path%,'\','\\\\') Action 2: Format value Field: GENRE Formatstring: $meta(GENRE,1)**

Great! The very first offered option already works perfect for me. Thanks for taking the time! I also like the alternatives, gives some insight in how this all works.

---

<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:25pm UTC](https://community.mp3tag.de/t/set-genre-to-root-folder-name/16890/5 "2026-02-09T12:25:40Z")

</div>

Closed on February 9, 2026, 12:25pm UTC


