# Leaving only the year

**URL:** https://community.mp3tag.de/t/leaving-only-the-year/65886
**Category:** Support
**Created:** [September 11, 2024, 12:48am UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886 "2024-09-11T00:48:35Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [September 11, 2024, 12:48am UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/1 "2024-09-11T00:48:35Z")

</div>

Hi

I'm trying to change some titles to leave only the year.

For example

Children Of The Sun (The Missunderstood 1967)  
A Touch Of Velvet A Sting Of Brass 2 (The Mood Mozaic 1966)  
All Along The Watchtower (The Alan Bown 1967)  
Azrael (The Nice 1967)  
But Cry (The Robb Storm Group 1966)

Would become

1967  
1966  
1967  
1967  
1966

Can someone advise on how to achieve this?

Grateful for any help.

🙂

---

<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: [September 11, 2024, 5:16am UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/2 "2024-09-11T05:16:12Z")

</div>

Try Convert\>Tag - Tag or an action of the type "Format value" for the field  
Formatstring: `$regexp('Children Of The Sun (The Missunderstood 1967)','.* (\d\d\d\d)\)',$1)`  
In which you replace the search string with the field name.

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [September 11, 2024, 12:40pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/3 "2024-09-11T12:40:15Z")

</div>

A more universal solution would be:  
Actions → Actions (Quick) → Replace with regular expression  
Field:  
`TITLE`  
Regular expression:  
`^.*(\d{4}).*$`  
Replace matches with:  
`$1`

---

<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: [September 11, 2024, 12:46pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/4 "2024-09-11T12:46:25Z")

</div>

> [@Casual\_Tea](#):
>
> A more universal solution would be:

Your suggestion would also treat  
MB Trac 1100  
Deutz D9006  
IHC 1046  
Herbert Grönemeyer - 4630 Bochum  
Spliff - 85555  
Wilson Picket - 634-5789 - Soulsville, U.S.A.  
Vice - Steady 1234

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [September 11, 2024, 12:47pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/5 "2024-09-11T12:47:15Z")

</div>

@chayes  
Maybe you could also tell us why you would like to reduce the content of the TITLE to 4 numbers?

These 4 numbers usually are the content of the YEAR or ORIGYEAR tag or maybe part of one of the date tags.

In which use cases would it be helpful to fill the TITLE with only 4 numbers?

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [September 11, 2024, 5:30pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/6 "2024-09-11T17:30:52Z")

</div>

Hi all

Thanks for your help. I applied this

> [@Casual\_Tea](#):
>
> Actions → Actions (Quick) → Replace with regular expression  
> Field:  
> `TITLE`  
> Regular expression:  
> `^.*(\d{4}).*$`  
> Replace matches with:  
> `$1`

and it works perfectly! It leaves the year and removes the text in exactly the way I was seeking. 🙂

BTW For my curiosity , how would the expression be modified to remove the year and leave only the text? 🙂

---

<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: [September 11, 2024, 5:35pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/7 "2024-09-11T17:35:21Z")

</div>

> [@chayes](#):
>
> how would the expression be modified to remove the year and leave only the text?

If you want to split the existing data into TITLE and YEAR I would suggest an action of the type "Guess value"  
Source pattern: %title%  
Target format string: `%title% (%year%)`

And a comment on

> [@chayes](#):
>
> and it works perfectly!

please see that the code also treats data that you may not want to treat as shown in a short list of examples in

> [@Leaving only the year](https://community.mp3tag.de/t/leaving-only-the-year/65886/4):
>
> Your suggestion would also treat MB Trac 1100 Deutz D9006 IHC 1046 Herbert Grönemeyer - 4630 Bochum Spliff - 85555 Wilson Picket - 634-5789 - Soulsville, U.S.A. Vice - Steady 1234

You may have others.

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [September 12, 2024, 12:29am UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/8 "2024-09-12T00:29:30Z")

</div>

> [@chayes](#):
>
> BTW For my curiosity , how would the expression be modified to remove the year and leave only the text? 🙂

Assuming that you also want to remove the space before the year, this would do the trick:  
Actions → Actions (Quick) → Replace with regular expression  
Field:  
`TITLE`  
Regular expression:  
`^(.*) \d{4}(.*)$`  
Replace matches with:  
`$1$2`

However, as @ohrenkino mentioned, this only works cleanly if your files all follow the pattern of your examples and may lead to unwanted/unexpected results if you have multiple 4-digit numbers in the strings.

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [September 12, 2024, 3:02am UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/9 "2024-09-12T03:02:31Z")

</div>

Many thanks. That does the job!

I understand the issue with other random 4-digit numbers in the title , but that should be the exception so will be manageable.

🙂

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [September 12, 2024, 2:15pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/10 "2024-09-12T14:15:49Z")

</div>

BTW

I think a way around the issue with more accurately identifying Year might be to have the regex only select four digits beginning with 19\* and 20\* in the two scenarios. Is this possible?

🙂

---

<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: [September 12, 2024, 3:11pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/11 "2024-09-12T15:11:09Z")

</div>

> [@chayes](#):
>
> 19\* and 20\*.

I think you started off fairly nicely with the parenthesis around the year.  
The

> [@Casual\_Tea](#):
>
> more universal solution

would take any 4 digits, even 4 digits which are part of numbers with more digits whereas the pattern that looks for parenthesis with 4 digits inside has a higher hit rate.  
Even if you look for titles that have a 19 or 20 at the beginning, you would get hits with titles like  
After the fire: 1980-F  
or  
20000 Meilen  
New Order - 1963  
Green Day - 2000 Lightyears  
Kraftwerk - Expo 2000

The expression would look like: `.*((19|20)\d\d).*`

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [September 12, 2024, 6:18pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/12 "2024-09-12T18:18:58Z")

</div>

I've played around with it a bit and while it won't eliminate all false matches, this one is pretty solid, at least for most examples provided in this thread:

```auto
^.*((19|20)\d{2})(?![\d-]).*$

```

 ![grafik](https://community.mp3tag.de/uploads/default/original/3X/e/9/e95733ccc10577543f6da0ef6440eb258e428cb7.png)  
And if the year is always followed by closing parenthesis and is preceded by a space, this would eliminate all mismatches (in the given examples).

```auto
^.* ((19|20)\d{2})\).*$

```

If you really want to go the specific route, this matches his examples pretty exactly.

```auto
^[\w]+ \([\w]+ ((19|20)\d{2})\)$

```

However, then it's no longer "universal". My initial proposed solution matches his examples well enough while still allowing other versions. Filtering and (more importantly) manually checking results are important when using any regex you don't fully understand and/or have tested.

---

<div class="post-metadata">

### Author: ![1HotJob](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/1/f0a364/32.png) [@1HotJob](https://community.mp3tag.de/u/1HotJob)
#### Post date: [September 12, 2024, 6:37pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/13 "2024-09-12T18:37:18Z")

</div>

> [@chayes](#):
>
> I'm trying to change some titles to leave only the year.

I think most of us are wondering why you want a song's filename reduced to a year. You can only have one song per year. Just Curious.

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [September 12, 2024, 10:45pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/14 "2024-09-12T22:45:35Z")

</div>

Thanks for your help guys. Problem solved!

🙂 🙂

For those wondering I'm just trying to strip out dates / text from certain Filenames either for their own sake , or to put the year back in a different place.

---

<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: [October 12, 2024, 10:45pm UTC](https://community.mp3tag.de/t/leaving-only-the-year/65886/15 "2024-10-12T22:45:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
