HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: stevehero on 2018-04-07 01:22:54

Title: Using title formatting to search for year in format YYYY-MM-DD
Post by: stevehero on 2018-04-07 01:22:54
Hi,

I've strings such as:
Albumname (2015-01-15) [CAT#]
Albumname (2015-01-15)


I was looking at the title function help for how to search digits but couldn't find anything. Or in the forum here.

I was looking an if statement to search that string 'YYYY-MM-DD' and if found do stuff.

I know in mp3tag you could do the following:
Code: [Select]
$if($eql($regexp(%album%,.+\d{4}-\d{2}-\d{2}.*,eqltrue),eqltrue),True,False)
Title: Re: Using title formatting to search for year in format YYYY-MM-DD
Post by: MordredKLB on 2018-04-09 19:05:19
Neglecting the fact that adding dates to your album titles is usually a bad idea*, you could do something like this:

Code: [Select]
$year($substr(%album%,$add($strrchr(%album%,'('),1),$sub($strrchr(%album%,')'),1)))
That's going to find the index of the last occurrence of ( in your album string and the last occurrence of ) which should hopefully contain the date, and then move those indexes to just encompass the date, then return that date as a substring to $year which should hopefully contain 2015. I didn't test it out so you might need to massage it slightly.

*You'd probably be better off using %date% and some other custom fields (%original release date% is what I use) to accomplish whatever it is you're trying to accomplish.
Title: Re: Using title formatting to search for year in format YYYY-MM-DD
Post by: stevehero on 2018-04-12 23:40:10
Thanks, I know but with this particular album, the date is necessary as it's a homemade compilation of all varying music from different years which I want to retain and just scrape the YYYY-MM-DD from the album.

Is there any easy way to match DDDD-DD-DD where D represents a digit as opposed to matching opening ( and closing ) as some albums may contain such chars?
Title: Re: Using title formatting to search for year in format YYYY-MM-DD
Post by: MordredKLB on 2018-04-13 00:32:20
Thanks, I know but with this particular album, the date is necessary as it's a homemade compilation of all varying music from different years which I want to retain and just scrape the YYYY-MM-DD from the album.

Is there any easy way to match DDDD-DD-DD where D represents a digit as opposed to matching opening ( and closing ) as some albums may contain such chars?
There's no regex functionality, no.
Title: Re: Using title formatting to search for year in format YYYY-MM-DD
Post by: stevehero on 2018-04-13 01:16:58
No problem, I thought I might have missed a way in the formatting help to do such a thing.

I've created a request a while ago for a regexp fn. Hopefully, it comes at some point. The only thing missing from foobar200 IMO.