Trim %Year% if beyond 4 characters


#1

I have numerous files where the year is listed as "2012-12-27". I want to trim this to only show the actual 4 digit year - "2012" for example.

I have tried the following:

$if($len(%Year%)>4,$cutRight(%Year%,6),%Year%)

This will trim everything after the first 4 digits for those files where the year is greater than 4 characters in length. However, when running this action, if it finds a file with only a 4 digit year, it is deleting it.

So, in the end, I want to be able to check the year field to see if it has more than for characters. If it does, I want to trim everything after 4 characters. If not... I don't want to edit it at all.

Can anyone please enlighten me on what I am doing wrong?

Many thanks in advance!!!


Help converting Year to a simpler format
#2
  1. What Tag-Type do you currently use (ID3v2.3 or ID3v2.4)?
  2. You should decide whether you want to do an update to the current version of Mp3tag.
    Note the changes made in Mp3tag v2.53 ...
    [2012-09-29] CHG: ID3v2.3 TYER/TDAT now merged into one YEAR field formatted as YYYY-MM-DD.
  3. Your format string is not correct, you should probably get a little closer to the Mp3tag Scripting Language.
  4. Your format string should look like this ...
$if($eql($len(%YEAR%),10),$cutRight(%YEAR%,6),%YEAR%)
  1. Your format string can be simplified ... to save only the four characters from the left ...
$left(%TAGFIELD%,4)

DD.20121228.0918.CET


#3

Thanks a BUNCH for your reply. It looks as though I was making it somewhat harder than what is should have been. Given that the "$left(%tagfield%, 4) worked just fine!

For anyone else that may run across this post and find it valuable... I will answer the questions posed...

  1. ID3v2.3
  2. I am currently running v2.54

I am still very new to the MP3Tag Scripting language. I cobbled together my initial stab from reading various posts. Your correction and directions are appreciated!!!

Just for clarity sake... if I am understanding your post correctly. MP3Tag will now be formatting all date fields as YYYY-MM-DD no matter what. Is that correct? I have seen a ton of my fields being updated to 2001-01-01 for example.... where Jan 1 was never even provided.

I don't like that it is addind month and day for the year field. In my opinion it is called "Year" for a reason. If the field were actually called "Date" then I would understand including Month and Day.

For now... I can run the updated action to get back to only showing the 4 digit year.

Again..... many thanks for the valuable and quick feedback!

Mirlynn


#4

I do follow your view of the semantic error.
The descriptor for the date field should not be "Year" or "Date" but correctly "ISO-Date" or "Date (ISO)".

DD.20121228.0948.CET