How to remove leading parts of a YEAR tag, but not with all of them?

It's hard for me to describe, so I'll just show you what I mean.

image

Some of my albums have the month and day included and some don't. I want to make it so all of the dates are just the year, like at the bottom of my picture.

I'm familiar with the $cutright function. I've been using:

$cutright(%year%, 6)

to remove the extra bits, but I've done that by manually selecting tracks that have the extra characters in it. I'm wondering what tag-to-tag format string could be constructed so I could just select all my tracks, and have it remove the 6 characters from the right on tracks with the extended dates and not remove any characters on tracks with just the year.

I'm not very knowledgeable when it comes to planning out scripts like this, but it seems like this could be done with some boolean function that checks if the YEAR field has more than 4 characters, and if it does, it runs the $cutright function. I also see that $len exists, so that could be used to check how many characters the field has.

I feel like I have all the pieces, I'm just not familiar with with formatting stuff like this. What string would you write for the problem I'm having?

What about keeping the left 4 numbers (the year) and cut away the part on the right side.
Something like
$left(%year%,4)

image

2 Likes

You could just use $left(%year%,4) to get the first four characters.

1 Like

:man_facepalming:

There's always a simpler solution I didn't think of. Thank you both!!

1 Like

Just to add one more:
$num(%year%,1)
would also cut away anything that is no number, here: everything starting with the first hypen