# Replace "Genre" tag from a Regex using the folder path

**URL:** <https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193>\
**Category:** Support\
**Created:** [August 2, 2017, 12:34pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193 "2017-08-02T12:34:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidLago](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@DavidLago](https://community.mp3tag.de/u/DavidLago)\
**Post date:** [August 2, 2017, 12:34pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/1 "2017-08-02T12:34:25Z")

</div>

Hello, all.

If there was a topic about it, I apollogize but I couldn't find (and got blocked from searching too much hahaha).

I'd like to have some help/guidance/explanation.

I have a folder structure with ~100 itens that looks like these two examples that I copied to the folder "TEST".

G:\TEST\Darkthrone [Nor] #Black Metal, Punk Metal\<b\>\<4 folders\>:  
 _Darkthrone [1992] A Blaze In The Northern Sky"  
Darkthrone [1993] Under a Funeral Moon  
Darkthrone [1994] Transilvanian Hunger  
Darkthrone [2016] Arctic Thunder_

G:\TEST\Monolord [Swe] #Stoner Metal, Doom Metal\<b\>\<2 folders\>  
_Monolord [2014] Empress Rising  
Monolord [2015] Vaenir_  
   
Those are the folders, they have their song files from within it.

I loaded the whole content of the folder "TEST" under Mp3 tag (all Darkthrone and Monolord album).

What I'm trying to do is:

**- Replace the field "Genre" with whatever string is after #**  
   
For example, for Darkthrone, the genre will become "Black Metal, Punk Metal"  
For Monolord, the genre will be Stoner Metal, Doom Metal.

I tried several tag/tag conversions, using the variable %\_folderpath% and tested some of my very limited REGEX skills, also tried %\_path%, and some other directories variables, also tried to place some %dummy% parameters in several places.

I know it's possible, but I couldn't figure out by myself. I wished someone could point it out and explain to me how it works.

Thanks.

- Dave

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [August 2, 2017, 1:03pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/2 "2017-08-02T13:03:00Z")

</div>

Action format value ![:mt_act:](https://community.mp3tag.de/uploads/default/original/1X/318aa654f7a0c7c178d869991f6e8680b214cfc0.png ":mt\_act:") :

```
Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)
```

---

<div class="post-metadata">

**Author:** ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)\
**Post date:** [August 2, 2017, 1:29pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/3 "2017-08-02T13:29:23Z")

</div>

Action Type: Guess Values  
Source: %\_parent\_directory%  
Format String: %dummy% #%genre%

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [August 2, 2017, 1:49pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/4 "2017-08-02T13:49:36Z")

</div>

Parent directory won't work as some of the OPs examples show 2 or 4 folders deep.

---

<div class="post-metadata">

**Author:** ![DavidLago](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@DavidLago](https://community.mp3tag.de/u/DavidLago)\
**Post date:** [August 2, 2017, 1:53pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/5 "2017-08-02T13:53:43Z")

</div>

QUOTE (stevehero @ Aug 2 2017, 12:03) \<{POST\_SNAPBACK}\>

Action format value ![:mt_act:](https://community.mp3tag.de/uploads/default/original/1X/318aa654f7a0c7c178d869991f6e8680b214cfc0.png ":mt\_act:") :

```
Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)<!--QuoteEnd--></div><!--QuoteEEnd-->

```

Thank youm @stevehero!

That's exactly what I wanted. It seems that the REGEX is way more complex than what I thought.

I was going to ask you to explain it to me, but I'll try to figure out myself, since it's not really easy to write the logic down.

Thank you!

---

<div class="post-metadata">

**Author:** ![DavidLago](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@DavidLago](https://community.mp3tag.de/u/DavidLago)\
**Post date:** [August 2, 2017, 1:56pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/6 "2017-08-02T13:56:07Z")

</div>

QUOTE (stevehero @ Aug 2 2017, 12:03) \<{POST\_SNAPBACK}\>

Action format value ![:mt_act:](https://community.mp3tag.de/uploads/default/original/1X/318aa654f7a0c7c178d869991f6e8680b214cfc0.png ":mt\_act:") :

```
Format: GENRE
FString: $regexp(%_path%,'.+?(#[^\\\\]+).+',$1)<!--QuoteEnd--></div><!--QuoteEEnd-->

```

Oh, actually, it's still writing the "#" to the genre. I would need to remove it, and start after that.

---

<div class="post-metadata">

**Author:** ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)\
**Post date:** [August 2, 2017, 2:12pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/7 "2017-08-02T14:12:35Z")

</div>

> [@stevehero](#):
>
> Parent directory won't work as some of the OPs examples show 2 or 4 folders deep.

Where do you see that in the examples?  
My interpretation of "4 folders" and 2 "folders" is just the amount of folders that are in the parent-directory, not a hierarchy of folders.

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [August 2, 2017, 2:14pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/8 "2017-08-02T14:14:15Z")

</div>

Use: $regexp(%\_path%,'.+?#([^\\]+).+',$1)  
Just moved the # outside the capture.

Maybe your right @poster. Read the OP quickly.

---

<div class="post-metadata">

**Author:** ![DavidLago](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@DavidLago](https://community.mp3tag.de/u/DavidLago)\
**Post date:** [August 2, 2017, 2:43pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/9 "2017-08-02T14:43:30Z")

</div>

> [@poster](#):
>
> Where do you see that in the examples?  
> My interpretation of "4 folders" and 2 "folders" is just the amount of folders that are in the parent-directory, not a hierarchy of folders.

Both of you are right. I mean, I didn't say that it was 2 or 4 folders deep, but actually, it's true! some of them (not these ones) are. Haha

---

<div class="post-metadata">

**Author:** ![DavidLago](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@DavidLago](https://community.mp3tag.de/u/DavidLago)\
**Post date:** [August 2, 2017, 3:04pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/10 "2017-08-02T15:04:10Z")

</div>

> [@stevehero](#):
>
> Use: $regexp(%\_path%,'.+?#([^\\]+).+',$1)  
> Just moved the # outside the capture.
> 
> Maybe your right @poster. Read the it quickly.

Thanks again, @stevehero.

I read your explanation a couple of times. The first part is understandable. I sometimes use these kind of regexps on basic shell scripts, sed commands or simple greps. But that format below still looks very weird for me to understand it easily. I think I need more practice.

btw, the last one, worked perfectly!

Thanks!

---

<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:26pm UTC](https://community.mp3tag.de/t/replace-genre-tag-from-a-regex-using-the-folder-path/19193/11 "2026-02-09T12:26:55Z")

</div>


