# regexp how can i get text between \[\] from directory to ALBUM

**URL:** <https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181>\
**Category:** Support\
**Created:** [August 29, 2015, 3:04pm UTC](https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181 "2015-08-29T15:04:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GSX1300](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@GSX1300](https://community.mp3tag.de/u/GSX1300)\
**Post date:** [August 29, 2015, 3:04pm UTC](https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181/1 "2015-08-29T15:04:03Z")

</div>

Hello,

i want to extract the text Germany between [and] and add this to the Album Tag

my folder is **C:\MP3\BAND-NAME\ALBUM-NAME[Germany]\</b\>**

My action is "tag field format" with  
Field : **ALBUM**  
Formatstring : **%album% $regexp(%\_directory%,[(.\*?)],$1)**

but i get REGEXP ERROR

any suggestions?  
Thanks in advance

---

<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:** [August 29, 2015, 3:32pm UTC](https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181/2 "2015-08-29T15:32:59Z")

</div>

Try $regexp(%\_directory%,'._[(._)]',$1)

---

<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:** [August 29, 2015, 3:35pm UTC](https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181/3 "2015-08-29T15:35:44Z")

</div>

> [@GSX1300](#):
>
> Hello, i want to extract the text Germany between [and] and add this to the Album Tag ... My action is "tag field format" with  
> Field : **ALBUM**  
> Formatstring : **%album% $regexp(%\_directory%,[(.\*?)],$1)**  
> but i get REGEXP ERROR any suggestions? Thanks in advance

In Mp3tag the square brackets clamp have the special meaning of "optional text", ...  
therefore the square brackets have to be enclosed in single apostrophes, when they should be used literally.  
Your formatstring will be syntactically correct this way: $regexp(%\_directory%,'['(.\*?)']',$1)  
... but the result is not what you want.

Try this ...

**Action "Format value" Tag-Field : ALBUM Formatstring: %ALBUM%' '$regexp(%\_directory%,'^.+?\[(.+?)\]$','$1') ... or ... Formatstring: %ALBUM%$regexp(%\_directory%,'.\*\[(.\*)\].\*',' $1') \_DIRECTORY : 'ALBUM\_NAME[Germany]' From ALBUM : 'The Album from' To ALBUM : 'The Album from Germany'**

DD.20150829.1935.CEST

---

<div class="post-metadata">

**Author:** ![GSX1300](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@GSX1300](https://community.mp3tag.de/u/GSX1300)\
**Post date:** [August 30, 2015, 11:29am UTC](https://community.mp3tag.de/t/regexp-how-can-i-get-text-between-from-directory-to-album/17181/4 "2015-08-30T11:29:14Z")

</div>

😃 your version works, thank you.

---

<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/regexp-how-can-i-get-text-between-from-directory-to-album/17181/5 "2026-02-09T12:25:50Z")

</div>

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


