# removing last word/number ?

**URL:** https://community.mp3tag.de/t/removing-last-word-number/12872
**Category:** Support
**Created:** [December 28, 2011, 9:29am UTC](https://community.mp3tag.de/t/removing-last-word-number/12872 "2011-12-28T09:29:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![sergeant](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@sergeant](https://community.mp3tag.de/u/sergeant)
#### Post date: [December 28, 2011, 9:29am UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/1 "2011-12-28T09:29:00Z")

</div>

Hey guys

How can I remove only the last word or number from a filename or a title ?

Example:

How do I eliminate "1957" from "ricky nelson - your true love 1957" and similar filenames ?

Please note that the words in the title field may vary therefore i need something to bulk eliminate ONLY the last word/number, regardless of how many words the title has.

Thanks

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [December 28, 2011, 12:19pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/2 "2011-12-28T12:19:55Z")

</div>

> [@sergeant](#):
>
> How can I remove only the last word or number from a filename or a title ?

Use a regular exp on '\_FILENAME' or 'TITLE'

REG EXP: \s+\w+$  
REPLACE WITH: BLANK

---

<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: [December 28, 2011, 12:46pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/3 "2011-12-28T12:46:58Z")

</div>

> [@sergeant](#):
>
> ... How can I remove only the last word or number from a filename or a title ? Example:  
> How do I eliminate "1957" from "ricky nelson - your true love 1957" and similar filenames ? ...

There are several ways to solve this little problem in Mp3tag.  
For example ...

... remove the last five characters from the TITLE string ...  
Action: Format value  
Field: TITLE  
Formatstring: $cutRight(%TITLE%,5)

... remove all trailing characters, starting from the last space character until end of TITLE string ...  
Action: Format value  
Field: TITLE  
Formatstring: $left(%TITLE%,$sub($strrchr(%TITLE%,' '),1))

... remove a trailing space and word character sequence from the TITLE string ...  
Action: Format value  
Field: TITLE  
Formatstring: $regexp(%TITLE%,'\s+\w+$',)

DD.20111228.1447.CET

---

<div class="post-metadata">

### Author: ![sketcherone](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@sketcherone](https://community.mp3tag.de/u/sketcherone)
#### Post date: [January 23, 2012, 5:11pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/4 "2012-01-23T17:11:09Z")

</div>

quick question--what would be the most efficient way to move this last word to another field, rather than delete?

For example, moving the year from the end of the title to the "year" tag?

---

<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: [January 23, 2012, 5:20pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/5 "2012-01-23T17:20:53Z")

</div>

Well, a "move" is actually a copy&delete, right?  
Unfortunately you have not given a real specimen just a vague idea - and in this context every single letter often makes the difference between ingenuity and failure.  
Anyway, let us assume, that you have a 4-digit year at the end of the TITLE.  
So: create an action to copy the whole of the TITLE to YEAR (see FAQs for that).  
Then: create an action for YEAR and replace with a regular expression:  
Search  
.\*(\d\d\d\d)$  
Replace with  
$1

Do the inverted for TITLE:  
(.\*) \d\d\d\d$  
replace with  
$1  
As I do not know what kind of delimiter can be found in front of the year-digits, it may be necessary to insert them in the search mask outside the brackets.

---

<div class="post-metadata">

### Author: ![sketcherone](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@sketcherone](https://community.mp3tag.de/u/sketcherone)
#### Post date: [January 23, 2012, 5:34pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/6 "2012-01-23T17:34:19Z")

</div>

> [@ohrenkino](#):
>
> Well, a "move" is actually a copy&delete, right?  
> Unfortunately you have not given a real specimen just a vague idea - and in this context every single letter often makes the difference between ingenuity and failure.  
> Anyway, let us assume, that you have a 4-digit year at the end of the TITLE.  
> So: create an action to copy the whole of the TITLE to YEAR (see FAQs for that).  
> Then: create an action for YEAR and replace with a regular expression:  
> Search  
> .\*(\d\d\d\d)$  
> Replace with  
> $1
> 
> Do the inverted for TITLE:  
> (.\*) \d\d\d\d$  
> replace with  
> $1  
> As I do not know what kind of delimiter can be found in front of the year-digits, it may be necessary to insert them in the search mask outside the brackets.

Thanks for the quick reply.

I had just modified the expression used to reverse artist names to accomplish this as well.

Regular Expression: ^(.+)\s(.+)$  
Replace with: $1 - $2

And then added a guess values action:  
%title% - %year%

---

<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: [January 23, 2012, 5:38pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/7 "2012-01-23T17:38:52Z")

</div>

> [@sketcherone](#):
>
> ...  
> And then added a guess values action:  
> %title% - %year%

Of course is the guess values action often much more elegant - provided you have a decent separator. Unfortunately this was not included in your example so I had to guess the value of the title as an unstructured string.

---

<div class="post-metadata">

### Author: ![sketcherone](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@sketcherone](https://community.mp3tag.de/u/sketcherone)
#### Post date: [January 23, 2012, 7:32pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/8 "2012-01-23T19:32:11Z")

</div>

> [@ohrenkino](#):
>
> Of course is the guess values action often much more elegant - provided you have a decent separator. Unfortunately this was not included in your example so I had to guess the value of the title as an unstructured string.

I was just using the example from the original poster--the only thing different in my question was the part involving relocating that information rather than deleting it.

For what it's worth, your post helped me to understand how parentheses work with regular expressions--something I'm having a hard enough time wrapping my head around.

---

<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:23pm UTC](https://community.mp3tag.de/t/removing-last-word-number/12872/9 "2026-02-09T12:23:32Z")

</div>


