Author Topic: Replacing dates into yyyy-mm-dd format using captured date values from tags  (Read 690 times)

Dalinar

  • Jr. Member
  • **
  • Posts: 63
Is there a way to Search and Replace in a tag field (either using the built in MusicBee capabilities or using that Additional Tagging Tools plugin) to do the following:

rewrite dates in certain formats to yyyy-mm-dd

the source format might be for example: mm/dd/yy

when there is only 2 years it means 20th century, anyhow I'm not against adding the 20 myself to the replacement string.

the key thing I want to be able to do is to capture the yy, mm and dd parts and use them to rewrite in the format e.g. 20yy-mm-dd

hiccup

  • Hero Member
  • *****
  • Posts: 6562
Let me firstly admit that the concept of 'dates' in tags is something I don't have a good or full understanding of myself.
But the answer to your question may depend on the type of tag that you are talking about.
(MusicBee allows you to set the tag type to e.g. 'string' or 'date' for custom and virtual tags)

For 'date' type tags, I think that your Windows regional settings dictate how they will show up.
For custom or virtual tags it shouldn't be too difficult to achieve what you want.

(This might provide you with some useful information:
https://getmusicbee.com/forum/index.php?topic=35868.msg196257#msg196257\
scroll down to the $Date part )

Dalinar

  • Jr. Member
  • **
  • Posts: 63
Let me firstly admit that the concept of 'dates' in tags is something I don't have a good or full understanding of myself.

the reason I have them is I like to trade live shows.

e.g.

Artist: Grateful Dead
Album: 1983-04-15 Community War Memorial Auditorium, Rochester, NY

However when shows come pre-tagged in MP3 or FLAC (SHNs don't) then there is no standard to how a person might have written the Album tag.

e.g. 4/15/83 Community War Memorial Auditorium, Rochester, NY

ah I forgot that people might not use leading 0s.. I guess it is more complicated than I thought to replace them.



hiccup

  • Hero Member
  • *****
  • Posts: 6562
Ok, so we have at least cleared up that you are not talking about an actual 'date' field, but about a regular string type tag.
Please enter, regex wizards…
Last Edit: April 24, 2022, 12:02:45 PM by hiccup

Dalinar

  • Jr. Member
  • **
  • Posts: 63
yes.. you replied to my post, which I quickly edited but not fast enough I guess.. Maybe you can change the quoted text to Album: instead of Title: just so that it doesn't confuse anyone, as the Title is used for the song name.

The Incredible Boom Boom

  • Hero Member
  • *****
  • Posts: 899
I would use mp3tag to accomplish what you're trying.

Do you know how to create regular expressions?

Zak

  • Member
  • Hero Member
  • *****
  • Posts: 2225
I keep seeing the Additional Tagging and Reporting Tools plug-in suggested in answers to questions like this.
I don't use it, so I just installed it to check it out.

And, well... hot diggity.

I know the plug-in has its fans, but I'll just say anyone that doesn't have Mp3tag in their tagging toolkit for stuff like this is spending a lot more time tagging tracks than they need to.

www.mp3tag.de/en

The best thing about Mp3tag is that you can group a lot of commands into a single Action Group.
So rather than try to construct one massive complicated command or regular expression to do all the work we can break it down into more digestible bite-size pieces.

In Mp3tag, select Actions > Actions to open the Action Groups list (or press Alt+6).
Click the New button (with the little star) to create a new Action Group and give it a meaningful name like "Format Album Date".

Assuming an Album tag in this format:

e.g. 4/15/83 Community War Memorial Auditorium, Rochester, NY

In Mp3tag, the command Format value assigns a value to a field (i.e. tag).

We can use this three times to pick out the parts of the date and save them for later.
Field:         TEMPYEAR
Format string: $RegExp(%Album%,'(\d{1,2})\/(\d{1,2})\/(\d{2}) (.*)','$3')
Field:         TEMPMONTH
Format string: $RegExp(%Album%,'(\d{1,2})\/(\d{1,2})\/(\d{2}) (.*)','$1')
Field:         TEMPDATE
Format string: $RegExp(%Album%,'(\d{1,2})\/(\d{1,2})\/(\d{2}) (.*)','$2')

We can use some the same command with some other functions to prepend the century to years that only have two digits.
As an added bonus we can check the value of two-digit years to set it to the correct century.
Field:         TEMPYEAR
Format string: $If($Eql($Len(%TempYear%),2),$IfGreater(%TempYear%,22,19%TempYear%,20%TempYear%),%TempYear%)

(You'd need to update the 22 in that formula each year to keep it current)

Mp3tag has a $Num function that can be used to pad digits with a specified number of zeroes so we can use that for the month and date:
Field:         TEMPMONTH
Format string: $Num(%TempMonth%,2)
Field:         TEMPDATE
Format string: $Num(%TempDate%,2)

Then we use the Format value command again to set the date using our newly formatted values:
Field:         DATE
Format string: %TempYear%-%TempMonth%-%TempDate%

Finally use the Remove fields commands to delete the temporary fields we used to construct the date:
Fields to remove: TempYear;TempMonth;TempDate

Putting all that together as a single Action in Mp3tag will result in this:



Load the tracks from your album into Mp3tag, run that one action, and they will all have their Date field set to 1983-04-15.

Another great time-saver in Mp3tag is a not-so-documented feature for keyboard access.
If you include an ampersand in your action title, that becomes the keyboard shortcut to run that command.
So you could call your action Format Album &Date for example, and then run it by pressing Alt+A, D.



(The Alt+A is Mp3tag's built-in key for the Actions menu)

An even-less-documented feature is that you can include a hash symbol to group commands into sub-menus.
Call the same action #Format Album &Date#&1. Month-Date-Year, and then run it by pressing Alt+A, D, 1.



This way you could make different versions of the same action for each of the different date formats your albums use and access each one with a different number.

You'll never tag faster than once you've committed those shortcuts to muscle memory.

-edit-
Updated to describe how to create a new Action Group.
Also, I forgot to mention that Mp3tag uses the Action Group title for the configuration file that stores its actions.
So you can't use characters in Action Group titles that would be invalid in a file name.  : / ? * etc.
Last Edit: April 27, 2022, 03:06:11 AM by Zak
Bee excellent to each other...

phred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8317
I'll just say anyone that doesn't have Mp3tag in their tagging toolkit for stuff like this is spending a lot more time tagging tracks than they need to.
@Zak-

I've had mp3tag in my bag of tricks long before I had MB. But I rarely use it. That being said, your "review" here has opened up my thinking of things I've thought about doing (within MB) but felt they were too convoluted to achieve.

So I'd like to request that when you have a little time, take your reply and post it in the Tips & Tricks section. I would suggest leaving the examples you have, and perhaps adding a few more general comments. I think a lot of folks would appreciate hearing/reading/learning about mp3tag.

Thanks.
Download the latest MusicBee v3.5 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
Check out the MusicBee Wiki.
How to post screenshots is here.

Zak

  • Member
  • Hero Member
  • *****
  • Posts: 2225
Well I didn't mean for it to be a review any more than explaining why I think it's the best tool for this particular job.

I tag all my tracks in Mp3tag before I add them to MusicBee. I have dozens of little actions like this set up for different tasks, album types etc. and it only takes a couple of minutes to tag an album just how I need for MusicBee to display it the way I want.

It's easier to provide examples in response to specific requirements than just describing generally what Mp3tag can do - its own documentation already does that - but I'll see what I can come up with.
(Busy now though, so might be a week or two)
Bee excellent to each other...

phred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8317
...but I'll see what I can come up with.
(Busy now though, so might be a week or two)
Understandable. I think an avid user such as yourself would be much better at providing a Tips & Tricks post than a less-than casual user like me.

Whenever you can get to it is fine. And if you can't, you can't.

Thanks for considering.
Download the latest MusicBee v3.5 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
Check out the MusicBee Wiki.
How to post screenshots is here.

The Incredible Boom Boom

  • Hero Member
  • *****
  • Posts: 899
Excellent write-up, @Zak. Not to take anything away from MusicBee and the Additional Tagging & Tools plugin, but mp3tag really fulfills its own purpose completely. As a kid starting off with Windows 3.1 and up to this very day, MusicBee and mp3tag are two of the best software programs I have ever used and are by far the best tools for managing music currently available.

@phred, I'd also be down to including some mp3tag write-ups on @Zak's thread in the Tips & Tricks board. Marrying mp3tag's tagging capabilities with MusicBee's management and display abilities should be considered mandatory for any serious digital audio enthusiast. Lol I've said this on the MusicBee subreddit, but (with the help of mp3tag's god-like tagging capabilities) MusicBee has allowed me to recreate the experience of visiting a record store or the back of Barnes & Nobles (large chain bookstore in the US) back when physical media was still ubiquitous.

phred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8317
@phred, I'd also be down to including some mp3tag write-ups on @Zak's thread in the Tips & Tricks board.
Thanks Boom Boom. Feel free to start the thread if you wish as Zak said it could be a week or two before he got to it.
Download the latest MusicBee v3.5 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
Check out the MusicBee Wiki.
How to post screenshots is here.

hiccup

  • Hero Member
  • *****
  • Posts: 6562
Marrying mp3tag's tagging capabilities with MusicBee's management and display abilities should be considered mandatory for any serious digital audio enthusiast.
Not if you know how to use Picard ;-)

I am curious about why many others like mp3tag so much though. I do have it on my system, and used it myself in the past, but after exploring and perfecting Picard I hardly ever looked at it again.
The benefits of a MusicBee/Picard marriage already has many threads, posts and explanations/tutorials on our forum.
So a dedicated MusicBee/mp3tag thread could indeed be interesting.

Dalinar

  • Jr. Member
  • **
  • Posts: 63