removing last word/number ?

Hey guys

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


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.


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

REG EXP: \s+\w+$

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+$',)


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?

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:
Replace with

Do the inverted for TITLE:
(.*) \d\d\d\d$
replace with
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%

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.