# Information from directory name to tag

**URL:** https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100
**Category:** Support
**Created:** [January 19, 2008, 11:50am UTC](https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100 "2008-01-19T11:50:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mihey](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/13edae/32.png) [@Mihey](https://community.mp3tag.de/u/Mihey)
#### Post date: [January 19, 2008, 11:50am UTC](https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100/1 "2008-01-19T11:50:00Z")

</div>

Hi,

I have a bunch of mp3s with empty **YEAR** tag, but each of the singles is contained in " **Artist - Year - Title**" folder. How do I extract the year from it into the **YEAR** tag?

By the way, I tried **Actions** , particularly **Replace with regular expression**. I matched the empty field and used scripting function in "replace with":

```
$regexp(%_directory%,.+\s-\s(\d+)\s-\s.+,$1)

```

But it seems not to recognize "%\_directory%" as a placeholder for parent directory (YEAR = "%\_directory%"). I couldn't find a list of placeholders to be used in scripting functions and took this one from Columns. M-m, was that wrong?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [January 19, 2008, 1:04pm UTC](https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100/2 "2008-01-19T13:04:44Z")

</div>

You are probably using the Replace with regular expression action in a wrong way and you should use a different action type.

You can try Format value  
Field: YEAR  
Format string: $regexp(%\_directory%,.+\s-\s(\d+)\s-\s.+,$1)

or Import value  
Guessing pattern: %\_directory%  
Format string: %dummy% - %year% - %dummy%

---

<div class="post-metadata">

### Author: ![Mihey](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/13edae/32.png) [@Mihey](https://community.mp3tag.de/u/Mihey)
#### Post date: [January 20, 2008, 9:23am UTC](https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100/3 "2008-01-20T09:23:03Z")

</div>

I used the first suggestion and it worked. 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:20pm UTC](https://community.mp3tag.de/t/information-from-directory-name-to-tag/6100/4 "2026-02-09T12:20:43Z")

</div>


