Trimming all but last four characters from a field

I need to write a function to trim all but the last four digits from the date (%YEAR% i think) of a bunch of MP3s. Currently most of them have "January 1, 2000" formatting and i would like to have everything other than the year removed.

I hope my question made sense and thank you for any help!

If it is always the last 4 characters you can use the function

1 Like

You could try an action of the type "Replace with regular expression" for YEAR
Search string: .*(\d\d\d\d)
Replace with: $1

1 Like

This worked, but I'm wondering if there is some redundancy in how I used this function.

When I create an action type of "Format Value" I am prompted to choose a field, (in this case YEAR), and I'm wondering if this makes part of "$right(%year%,4)" redundant and if this could cause any problems. I will be saving this function to use whenever I convert from my FLAC collection to MP3.

And thank you for the fast reply!

It is not redundant, because you can write the content of $right(%year%,4) - the 4 numbers 2000 in your example - in every tag you want. Not only into the choosen YEAR tag, but also into every other tag.

If you choose YEAR in this case, you overwrite the current content "January 1, 2000" with "2000".
If you would choose another tag like COMMENT as Field:
you would copy the part "2000" from YEAR and write it into COMMENT.
The YEAR tag would be left unchanged, the current content of COMMENT would be replaced.

1 Like

Got it, hadn't properly wrapped my head around the answer yet but this makes complete sense now. Thank you to everyone!

1 Like

I guess this really depends on what your end requirement is. If you don't want to keep the month and date (I don't think too many players will respond to "January") then discarding this info when replacing the lengthy %year% tag value with the newly updated 4 digits isn't redundant. However if you feel that you may need to keep that original data intact for some future purpose, you may want to at least copy that info to a custom tag field for now. Then you can update the actual %year% tag and still have both. The amount of data consumed for this is really insignificant compared to the music anyhow.

1 Like

My confusion was me not realizing how the format string actually worked, the "year" being used to call from a field while writing to a field was handled separately. It all makes sense now and from here I think I can probably cobble together my own arguments once I find a list of fields and functions. Thank you again!

No easier said than done - see the documentation:

1 Like

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