Need Help with Action Item

When using dBpoweramp to rip CDs to FLAC with Vorbis comments, we often get YEAR information from web sources in this format: yyyy mm dd.

We set up dBpoweramp to save the Vorbis Comment as a DATE tag. This is the date of release of the album. So the YEAR information from the on-line source of information is converted to a DATE tag when we rip the CD. We want the DATE tag to retain all 8 digits when they exist.

Now we would like a script to create a YEAR tag fromt he DATE tag. The script should "keep" the first four numerals and discard the remainder. The DATE tag should not be discarded.

Given this metadata:

YEAR=yyyy mm dd

We would like to use an Action item to generate this:

DATE=yyyy mm dd
YEAR=yyyy

Can someone please advise us on how to write the Action item?

Thanks in advance for your help.

d2b

This could be tricky. Pulling the year out of the date is the easy part.

Here's the problem: The standard Vorbis Comment field name for dates is DATE. Mp3tag maps the internal name YEAR to the standard DATE field. As long as that mapping exists, you can't write both DATE and YEAR.

You can remove the mapping (never really tried it and I don't feel like testing it) in Tools > Options > Tags > Mapping. This should allow you to work with both fields, but I guarantee that it's going to get very confusing. What you'll end up doing is writing the year to the YEAR field. But since that's not a standard field name, it's not likely to be recognized by any software that you use, and you're still going to have YYYY MM DD formatted data in the DATE field.

What I would probably do if I wanted to preserve the YYYY MM DD data is first copy it to a non-standard field, maybe ORIGINALDATE or something similar. Then convert the date within YEAR to only keep the year portion. This would require an action group containing two actions. The following should work:

Action type: Format value
Field: ORIGINALDATE
Format string: $iflonger(%year%,4,%year%,%originaldate%)

Action type: Guess values
Source format: %year%
Guessing pattern: %year% %dummy%

The first action will copy any dates longer than four characters to the ORIGINALDATE field. It won't create the field if the date isn't more than four characters, so it should also avoid overwriting it if you run the action group more than once.

The second action leaves only the first part of the date (anything before the first space). Running it more than once will be safe and will leave the DATE field unchanged on subsequent runs. If your dates are sometimes formatted other than YYYY MM DD (say YYYY-MM-DD, or M-D-YY) then it will require something smarter, probably using a regular expression.