# Filling in the Year field

**URL:** <https://community.mp3tag.de/t/filling-in-the-year-field/14759>\
**Category:** Support\
**Created:** [May 26, 2013, 9:56am UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759 "2013-05-26T09:56:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glader](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/3e96dc/32.png) [@Glader](https://community.mp3tag.de/u/Glader)\
**Post date:** [May 26, 2013, 9:56am UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759/1 "2013-05-26T09:56:50Z")

</div>

So, I've decided to dig in and automate as much of my regular tagging routine as possible through the Actions system, but this is where I've hit a bit of a snag:

I'm trying to add an action to fill/format the year field if necessary.  
If year is set to four digits, I want to keep the tag.  
If it is set to something longer (such as 2007-07-37) I want to just keep the first four chars  
If it's blank, I want to guess the year based off the name of the directory the file is in.

What I've got so far is

$if(%year%, $left(%year%,4), \<???\>)

What I'm missing is the \<???\> bit where I WANT to have [12]\d{3} from %\_directory%  
Anyone see how I can make this happen? =)

---

<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:** [May 26, 2013, 10:49am UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759/2 "2013-05-26T10:49:09Z")

</div>

> [@Glader](#):
>
> ... I WANT to have [12]\d{3} from %\_directory%  
> ...

Please give an example of a real %\_directory% contents. And tell us which data you want to cut from it.

PS: just a personal footnote:  
How often does this happen that the year is not filled but can be found in the folder name? I'd say: once in the lifetime of a track. So is it worth it to have an action of its own instead of using a simple filter (%year% MISSING) and then a converter statement that shows the probable outcome?  
The other question I cannot solve: how come that the folder has the correct year but the file has not? Usually I tag the files first and then create a folder structure so the file has always the correct year, the folder might not ...

---

<div class="post-metadata">

**Author:** ![Glader](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/3e96dc/32.png) [@Glader](https://community.mp3tag.de/u/Glader)\
**Post date:** [May 26, 2013, 12:39pm UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759/3 "2013-05-26T12:39:01Z")

</div>

I can't find any instances right now of albums missing the year field but it does happen once in a while. The format of %\_directory% could vary greatly, which is why I want to use a regular expression to extract any four digit sequence starting with a 1 or a 2 (1xxx or 2xxx).

---

<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:** [May 26, 2013, 1:07pm UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759/4 "2013-05-26T13:07:14Z")

</div>

> [@Glader](#):
>
> I can't find any instances right now of albums missing the year field but it does happen once in a while. The format of %\_directory% could vary greatly, which is why I want to use a regular expression to extract any four digit sequence starting with a 1 or a 2 (1xxx or 2xxx).

The reason why I ask: you gave as example

> [@](#):
>
> [12]\d{3}

which has the backslash in it - which is usually part of a pathname. So it looks to me as though it is not a plain \_DIRECTORY variable.  
If you wand to extract a substring from a variable you can use one of the functions $left, $right or $mid. And to find a certain character you can use the $strstr function.  
As this will lead to a rather longish term I still suggest that you do it with a filter and the converter Filename -Tag and something like  
%dummy% - %year%\%dummy%.

---

<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:24pm UTC](https://community.mp3tag.de/t/filling-in-the-year-field/14759/5 "2026-02-09T12:24:30Z")

</div>

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


