Hi all, I'm the first to admit I'm RegEx impaired, so I greatly appreciate your help! I've combed these threads trying to find an answer to my specific date formatting question and have tried several solutions, but can't seem to get them to work. I'm hoping someone can help me figure out what I'm doing wrong!
I have a few thousand MKV files, and I'd like to populate the YEAR field with the file modified date in YYYYMMDD format. No spaces, capital Os, dots, dashes or slashes because the date won't display properly in the Windows properties for the files if non-numeric characters are included.
Using the Tag ==> Tag function and this format string works beautifully if the file modified date has a two digit month and two digit day. For example, if the file modified date is 10/24/2023
$regexp(%_file_mod_date%,(..)/(..)/(....),$3$1$2) yields 20231024, which is the format I'm seeking.
Where I run into problems is when the file modified date has a month or day with one digit.
For example, if the file modified date is 6/6/2024
$regexp(%_file_mod_date%,(..)/(..)/(....),$3$1$2) yields no change, 6/6/2024.
I can use this format string, but it does not create a two digit day or year, and the YYYYMD format won't display properly in Windows.
$regexp(%_file_mod_date%,(.)/(.)/(....),$3$1$2) yields 202466.
I've tried manually padding the format string with zeroes, but can't seem to figure out how to properly escape the 0 in a way that RegEx understands. For example, using apostrophes:
$regexp(%_file_mod_date%,(.)/(.)/(....),$3'0'$1'0'$2) yields 6. Not helpful.
I've also tried using $num(%file_mod_date%,2) in the format string to pad the one digit numbers to two, but clearly I'm doing it wrong as I get syntax errors.
The closest option I've found is to put capital Os in the format string, which gives a value that looks correct, but then Windows only displays the year, not the full string, in the file properties.
$regexp(%_file_mod_date%,(.)/(.)/(....),$3O$1O$2) yields 2024O6O6
Looks good, but again, Windows won't display the full string.
I would greatly appreciate your assistance with a solution that works! Thank you ![]()