Find date in the file name and change format


#1

I have several thousand MP3 files of various radio shows in which the broadcast date is part of the filename. I would like include this date in the DATE field of the ID3v2.3 tag. The dates are all in in different positions of the filename - some are at the beginning, some in the end and others in the middle of the name. Is it possible to extrapolate those dates and copy them to the DATE field?

Also, how can I accurately change the format from dd.mm.yyyy to yyyy mm dd?

I found a previous topic (Format Date in File Name) from 2008 which discussed this, but I am unable to receive the desired results.

For instance, I created an Action to convert the date using the following regular expression:

$regexp(%_date%,(\d\d)\.(\d\d)\.(\d\d\d\d),$3.$1.$2)

Based on the information provided in the thread mention above, I was under the impression it would change the date format from 08.24.1995 to 1995.08.24. However, nothing at all happens when I use that action.

Any tips would be very much appreciated.

Thanks!
Ken


#2

Do you have a field %_date% or %date%?
The field %date% is only 4 digits long.

If you want to save the accurate date of a track, use %releasetime%

If the string is somewhere in the filename, use an action of the type “Guess values” where you cut off the undesired bits with %dummy%, e.g.

%dummy% - %releasetime% - %dummy%


#3

Thanks for the reply.

I was using field %date%. All the files that currently have any date entered in that field display the entire date - month, day, year. Not just 4 digits.

Nonetheless, I added dates to the %releasetime% field in a few different files and changed the action/reg exp accordingly to match that field, but the results are just the same. It doesn’t change the format of the date. Would like to at least get that working before moving on to the “Guess values” issue.


#4

You can use the function
Convert>Tag-Tag
for testing.
Enter as format string:
$regexp(‘08.24.1995’,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

and you see in the preview
"1995.08.24"
You can also test
$regexp(%date%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

So check if the pattern in the field actually matches the pattern of the regular expression.
If there is no match, the the regular expression returns the search string.


#5

The Convert>Tag-Tag works to show the reformatted date in the preview.

However, the other regexp to actually change the dates in the files in question does nothing for me. Regardless if I attempt to use %date% or %releasetime%. The dates in both fields in my test file are precisely 08.24.1995, but they are not reformatted to the desired date format when running the action.


#6

That is good as it shows that there is no syntax error in your local implementation.

You have not yet showed us what kind of action you use for which field.
A “Format value” action assigns a value that is determined by the format string to a named field.
So e.g. to swap the date around in the field DATE, you have to create the action for that field (DATE).
Enter the format string that supplies the correct data, e.g. the one that you have seen that is working.
So an example would be:
Format value
Field: DATE
Format string: $regexp(%date%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)


#7

Apparently I’m not explaining clearly what I’m trying to do and what I would like to happen.

I have a date field in a particular MP3 file. In this case, it is RELEASETIME and the date is entered in that field as 08.24.1995. I wish to reformat that date to: 1995.08.24.

I have tried using the Action command in a few different ways to make that happen. The first attempt was creating an Action type of “Replace with regular expression”. The two different methods I tried were:

$regexp(%date%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)
and
$regexp(%releasetime%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

I have now also tried an Action type of “Format value” as per your last reply. The two different methods I have tried for this are:

$regexp(%date%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)
and
$regexp(%releasetime%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

All of the above did nothing to change the actual format of the date shown in the RELEASETIME field.

And now I’m getting a bit confused myself. I had originally been trying to use the DATE field, but earlier you said it’s limited to 4 digits (even though the version I’m using of MP3TAG allows me to enter the full date of month, day and year and I have 8 digits in my dates: 2 for month, 2 for day and 4 for year. However, in your replies you refer to DATE. So now I’m not sure if I’m supposed to be using DATE or RELEASETIME.

I hope I have explained more clearly now. I just wish there would be something that will actually work to change the formats in the date fields of these files from mm.dd.yyyy to yyyy.mm.dd.

Thank you!

Ken


#8

I just tested ít and this format-string in an action of the type “Format Value” did exactly what you want to achieve.


#9

RELEASETIME in its full beauty has the format yyyy.mm.ddTHH:MM:SS

A DATE field really has only four digits like 3112 for the last day in a year.
If you say that

you leave out the dots which makes up for 10 characters in all. But perhaps you meant that.

If you use an action of the type “Replace with regular expression” then you can’t use a format string but you have to enter a regular expression. The function $regexp() is a scripting function that emulates the action. So you had an evaluated regular expression in an action to replace with a regular expression. This will never lead to a reasonable result. I wonder where you entered the $regexp() in that action.

Please show us the contents and name of the field that you want to manipulate,
show us the exact action that you use with all its parameters.


#10

I have started from zero in hopes I could get something to work. Created a new folder and added a few mp3 files that I wish to have the date reformatted.

Images have been created and linked in this post through each step I performed.

Initial date in RELEASETIME is: 08.24.1995

Next step was to create a new Action group. I call it ConvertDate.

Selected Format value as Action type

Within the Format value Action type, I chose RELEASETIME as the Field and for the Format string, entered:
$regexp(%releasetime%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

The final action appears as:
Format value “RELEASETIME”: $regexp(%releasetime%,(\d\d).(\d\d).(\d\d\d\d),$3.$1.$2)

After using that particular Action, a window appears stating:
Formatted tags in 1 of 1 files.
0 of 1 files renamed.

The end result is the RELEASETIME date which remains at: 08.24.1995. So, I don’t know what tag the program is referring to when it states that 1 of 1 tags has been formatted because the only tag I am interested in being formatted stays exactly the same.


#11

You can interactively check out how a formatstring works by applying the converter “Tag-Tag”.

Field: TEST

Formatstring: $regexp(%_filename%,’^.(\d{1,2}).(\d{1,2}).(\d{4}).$’,’$3.$1.$2’)
… when the given MDY date string is part of the filename.

Formatstring: $regexp(%RELEASETIME%,’^.(\d{1,2}).(\d{1,2}).(\d{4}).$’,’$3.$1.$2’)
… when the given MDY date string is part of the tagfield RELEASETIME.

DD.20170328.0651.CEST


#12

Have you checked the extended tags dialogue afterwards to check if another field has been created?

Also: what kind of tag versions are in the files? Only V1 and/or V2 or also APE?
What are your settings in respect to APE? These tags should get deleted and read but never be saved.


#13

Note: According to ISO 8601 international standard format …
The datetime string in the tag field RELEASETIME can have the format …
YYYY-MM-DDTHH:MM:SS

See also …
https://en.wikipedia.org/wiki/ISO_8601
https://de.wikipedia.org/wiki/ISO_8601

DD.20170421.1355.CEST