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