# Artist from a part of the directory with regex

**URL:** <https://community.mp3tag.de/t/artist-from-a-part-of-the-directory-with-regex/41208>\
**Category:** Support\
**Created:** [March 26, 2018, 10:20am UTC](https://community.mp3tag.de/t/artist-from-a-part-of-the-directory-with-regex/41208 "2018-03-26T10:20:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mudan](https://community.mp3tag.de/u/mudan)\
**Post date:** [March 26, 2018, 10:20am UTC](https://community.mp3tag.de/t/artist-from-a-part-of-the-directory-with-regex/41208/1 "2018-03-26T10:20:41Z")

</div>

Hi,

I have around 10.000 files that i want to organize. I am trying to fill the artist tag with a regexp expression that matches a part of the directory path. But nothing i try seems to work...

The folderpath is: D:\topfolder\subfolder\artist\album\

these are my settings in the replace with regular expression action:

**Field:** ARTIST(also tried %artist% btw)  
**Regular expression:** $regexp(%\_folderpath%,^D:\topfolder\subfolder\(._?)(?:\(._?)(.\*?))?$)  
**Replace by:** $1

I have tried quoting like this '^D:\topfolder\subfolder\(._?)(?:\(._?)(.\*?))?$' but that is not working either...  
I tested the regexp on [regex101.com](http://regex101.com) with ' as a delimiter....

What should i do to get this to 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:** [March 26, 2018, 10:51am UTC](https://community.mp3tag.de/t/artist-from-a-part-of-the-directory-with-regex/41208/2 "2018-03-26T10:51:16Z")

</div>

There is the function Convert\>Filename-Tag.  
You could try:  
Format string: `%artist%\%dummy%\%dummy%`  
or  
Format string: `%artist%\%album%\%dummy%`

If you want so see more about regular expressions in MP3tag, have a look at the help:

> **[Replace with Regular Expression – Mp3tag Documentation](https://docs.mp3tag.de/actions/replace-regexp/)**
>
> Documentation on the Replace with Regular Expression action type that can be performed as Quick Action or as reusable workflow from Action Groups. Mp3tag is the universal Tag Editor.

A good test environment to test your expression would be the function Convert\>Tag-Tag.  
Also, I think that the $regexp() function is invalid in the action "Replace with regular expression)".

---

<div class="post-metadata">

**Author:** ![mudan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mudan](https://community.mp3tag.de/u/mudan)\
**Post date:** [March 26, 2018, 11:01am UTC](https://community.mp3tag.de/t/artist-from-a-part-of-the-directory-with-regex/41208/3 "2018-03-26T11:01:20Z")

</div>

Ah, thank you very much. That's much easier!

---

<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/artist-from-a-part-of-the-directory-with-regex/41208/4 "2026-02-09T12:27:19Z")

</div>


