# help! grab year from filename? (tricky!)

**URL:** https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522
**Category:** Support
**Created:** [February 25, 2007, 4:42pm UTC](https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522 "2007-02-25T16:42:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vmueller](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vmueller](https://community.mp3tag.de/u/vmueller)
#### Post date: [February 25, 2007, 4:42pm UTC](https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522/1 "2007-02-25T16:42:26Z")

</div>

Hi,

I'm not able to figure out how to create a regular expression for the following mp3 filename format, so that I can create tags from the filename. Here is the format:

Herbie Hancock 1972 - Sextant - 01 Rain Dance.mp3  
artist year - album - tracknumber title

Specifically I am having problem with the year, when the artist has more than one name (first name and last name). It usually gives me

Artist: Herbie  
Year: Hancock 1972  
Album: Sextant  
etc.

Does anyone have any ideas on how to parse a filename like that? (My knowledge of regex is not good, so it may be easy for somebody who knows their regex)

Thanks

---

<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: [February 25, 2007, 9:36pm UTC](https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522/2 "2007-02-25T21:36:53Z")

</div>

> [@vmueller](#):
>
> ... I'm not able to figure out how to create a regular expression for the following mp3 filename format, so that I can create tags from the filename. Here is the format:  
> Herbie Hancock 1972 - Sextant - 01 Rain Dance.mp3  
> artist year - album - tracknumber title ...

I think you do not need a regular expression featured action.  
You may get what you want only by invoking the ready built in converter action 'filename - tag' using the appropriately format string.  
 ![](https://community.mp3tag.de/uploads/default/original/2X/a/a8eb96d2d7075c1b57f2edb7995d4b4035e90992.jpg)

DD.20070225.2338

Edit:

Well, my proposal above was a quick shot, only matching those strings that have the identical structure like your sample string.  
So you might want to do an action using regular expressions?

Here comes an action group set, that might do what you want.

Action #1:  
_Action type:_ **Format value**  
_Field:_ **VMUELLER\_ARTIST**  
_Formatstring:_ **%\_FILENAME%**

Action #2:  
_Action type:_ **Format value**  
_Field:_ **VMUELLER\_YEAR**  
_Formatstring:_ **%\_FILENAME%**

Action #3:  
_Action type:_ **Format value**  
_Field:_ **VMUELLER\_ALBUM**  
_Formatstring:_ **%\_FILENAME%**

Action #4:  
_Action type:_ **Format value**  
_Field:_ **VMUELLER\_TRACK**  
_Formatstring:_ **%\_FILENAME%**

Action #5:  
_Action type:_ **Format value**  
_Field:_ **VMUELLER\_TITLE**  
_Formatstring:_ **%\_FILENAME%**

Action #6:  
_Action type:_ **Replace with regular expression**  
_Field:_ **VMUELLER\_ARTIST**  
_Regular expression:_ **^(.+?) (\d+) - (.+?) - (.+?) (.+?)$**  
_Replace matches with:_ **$1**

[] case-sensitive comparison

Action #7:  
_Action type:_ **Replace with regular expression**  
_Field:_ **VMUELLER\_YEAR**  
_Regular expression:_ **^(.+?) (\d+) - (.+?) - (.+?) (.+?)$**  
_Replace matches with:_ **$2**

[] case-sensitive comparison

Action #8:  
_Action type:_ **Replace with regular expression**  
_Field:_ **VMUELLER\_ALBUM**  
_Regular expression:_ **^(.+?) (\d+) - (.+?) - (.+?) (.+?)$**  
_Replace matches with:_ **$3**

[] case-sensitive comparison

Action #9:  
_Action type:_ **Replace with regular expression**  
_Field:_ **VMUELLER\_TRACK**  
_Regular expression:_ **^(.+?) (\d+) - (.+?) - (.+?) (.+?)$**  
_Replace matches with:_ **$4**

[] case-sensitive comparison

Action #10:  
_Action type:_ **Replace with regular expression**  
_Field:_ **VMUELLER\_TITLE**  
_Regular expression:_ **^(.+?) (\d+) - (.+?) - (.+?) (.+?)$**  
_Replace matches with:_ **$5**

[] case-sensitive comparison

This emits following tags:  
 ![](https://community.mp3tag.de/uploads/default/original/2X/3/324b943d985be3f6fdff86b1a65c6588705a56ad.jpg)

DD.20070225.2357

![](https://community.mp3tag.de/uploads/default/original/2X/a/a8eb96d2d7075c1b57f2edb7995d4b4035e90992.jpg)

![](https://community.mp3tag.de/uploads/default/original/2X/3/324b943d985be3f6fdff86b1a65c6588705a56ad.jpg)

---

<div class="post-metadata">

### Author: ![vmueller](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vmueller](https://community.mp3tag.de/u/vmueller)
#### Post date: [February 26, 2007, 9:00pm UTC](https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522/3 "2007-02-26T21:00:49Z")

</div>

DetlevD,

Thanks for the in-depth reply. So I made an action group, exactly like you outlined. However, when I selected a file and ran the action, none of the tags showed up in their fields. Am I doing something wrong?

Thanks,  
Vergil

---

<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: [February 27, 2007, 12:13am UTC](https://community.mp3tag.de/t/help-grab-year-from-filename-tricky/4522/4 "2007-02-27T00:13:38Z")

</div>

> [@vmueller](#):
>
> ... However, when I selected a file and ran the action, none of the tags showed up in their fields. Am I doing something wrong?

Well, there are always occasions to do something wrong, and as always there is no chance to see from over here what might going wrong on your side.  
My example works with custom tags.  
You may use **Extended Tag View [Alt-T]** or set up new **columns** for the custom tags in the grid file list.  
Keep in mind that you have to adapt the field names from my example to your own needs.

DD.20070227.0220

---

<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/help-grab-year-from-filename-tricky/4522/5 "2026-02-09T12:20:10Z")

</div>


