# Release time and date from filename

**URL:** <https://community.mp3tag.de/t/release-time-and-date-from-filename/15549>\
**Category:** Support\
**Created:** [March 1, 2014, 7:39pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549 "2014-03-01T19:39:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![madramadra](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@madramadra](https://community.mp3tag.de/u/madramadra)\
**Post date:** [March 1, 2014, 7:39pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/1 "2014-03-01T19:39:29Z")

</div>

Have a bunch of old podcasts, with no release time or date but with a filename of:

060210 - FILENAME.mp3

where 060210 is a date of 10th February 2006.

I wish to know how I could go about batch processing these files so that they have a correct releasetime and releasedate according to the particular date at the beginning of the filename. So for that file in particular, it would have a releasetime and releasedate of 10th February 2006 in the format of YYYY-MM-DDThh:mm:ssZ.

Another question, I have another batch with filenames of:

01 - 2001-11-10  
02 - 2001-11-17  
03 - 2001-11-24  
etc.

and I wish to do the same as above, with releasetime and releasedate.

I would be eternally grateful if someone could help me, this is a bit too complicated for me.

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [March 1, 2014, 8:56pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/2 "2014-03-01T20:56:14Z")

</div>

For 060210 - FILENAME.mp3 you can use an action or tag-tag ![:mt_ttt:](https://community.mp3tag.de/uploads/default/original/1X/f8c08645074b054ac98070f71500627b98311bd2.png ":mt\_ttt:") like:

1. **Field:** RELEASETIME

**Format string:** $regexp(%\_FILENAME%,^([0-2][0-9])(\d\d)(\d\d).+,$3-$2-20$1T12:00:00Z)

 

BUT it seems this doesn't work as it should. This regexp should only match a year which is 2000 up to 2029 but I believe there is a bug and it returns unfavoured results.

2. So you can use this instead and for RELEASEDATE also: **Field:** RELEASETIME

**Format string:** $regexp(%\_FILENAME%,^(\d\d)(\d\d)(\d\d).+,$3-$2-20$1T12:00:00Z)

But be careful that you only run it on 2000 year upwards. The time format is 12:00:00. It's just adding a dummy time in but iTunes can read the RELEASETIME without that there so it's optional. It all depends on the software/players you use.

3. For filenames with 01 - 2001-11-10.mp3 use in the format field for RELEASETIME and RELEASEDATE: $regexp(%\_FILENAME%,.+?\s-\s(\d\d\d\d)-(\d\d)-(\d\d)$,$3-$2-$1T12:00:00Z)

As I've said example 1 doesn't work as it should. Example 3 works in an action but no.2 example does not. Having said that they all do in the tag-tag ![:mt_ttt:](https://community.mp3tag.de/uploads/default/original/1X/f8c08645074b054ac98070f71500627b98311bd2.png ":mt\_ttt:") ![:unsure:](https://community.mp3tag.de/uploads/default/original/1X/cfaeba84fe6704387c5b34dfdd8172bd51b6f533.gif ":unsure:")

When in an action example no.2 formats the fields with all the info from the \_FILENAME whereas in tag-tag it does not. Also I'd like if someone could try out the no.1 action too that would be great or know why it doesn't work. See attached my troublesome action.  
[\_Script\_Test\_TEST\_madmadra.mta](https://community.mp3tag.de/uploads/default/original/2X/8/8bf08c1bd6347a86477614260fc10fd271fbdde6.mta) (433 Bytes)

[\_Script\_Test\_TEST\_madmadra.mta](https://community.mp3tag.de/uploads/default/original/2X/8/8bf08c1bd6347a86477614260fc10fd271fbdde6.mta) (433 Bytes)

---

<div class="post-metadata">

**Author:** ![madramadra](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@madramadra](https://community.mp3tag.de/u/madramadra)\
**Post date:** [March 1, 2014, 9:23pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/3 "2014-03-01T21:23:06Z")

</div>

> [@stevehero](#):
>
> For 060210 - FILENAME.mp3 you can use an action or tag-tag ![:mt_ttt:](https://community.mp3tag.de/uploads/default/original/1X/f8c08645074b054ac98070f71500627b98311bd2.png ":mt\_ttt:") like:
> 
> 1. **Field:** RELEASETIME
> 
> **Format string:** $regexp(%\_FILENAME%,^([0-2][0-9])(\d\d)(\d\d).+,$3-$2-20$1T12:00:00Z)
> 
>  
> 
> BUT it seems this doesn't work as it should. This regexp should only match a year which is 2000 up to 2029 but I believe there is a bug and it returns unfavoured results.
> 
> 2. So you can use this instead and for RELEASEDATE also: **Field:** RELEASETIME
> 
> **Format string:** $regexp(%\_FILENAME%,^(\d\d)(\d\d)(\d\d).+,$3-$2-20$1T12:00:00Z)
> 
>  
> 
> But be careful that you only run it on 2000 year upwards. The time format is 12:00:00. It's just adding a dummy time in but iTunes can read the RELEASETIME without that there so it's optional. It all depends on the software/players you use.
> 
> 3. For filenames with 01 - 2001-11-10.mp3 use in the format field for RELEASETIME and RELEASEDATE: $regexp(%\_FILENAME%,.+?\s-\s(\d\d\d\d)-(\d\d)-(\d\d)$,$3-$2-$1T12:00:00Z) 
> 
> As I've said example 1 doesn't work as it should. Example 3 works in an action but no.2 example does not. Having said that they all do in the tag-tag ![:mt_ttt:](https://community.mp3tag.de/uploads/default/original/1X/f8c08645074b054ac98070f71500627b98311bd2.png ":mt\_ttt:") ![:unsure:](https://community.mp3tag.de/uploads/default/original/1X/cfaeba84fe6704387c5b34dfdd8172bd51b6f533.gif ":unsure:")
> 
>  
> 
> When in an action example no.2 formats the fields with all the info from the \_FILENAME whereas in tag-tag it does not. Also I'd like if someone could try out the no.1 action too that would be great or know why it doesn't work. See attached my troublesome action.  
> [\_Script\_Test\_TEST\_madmadra.mta](https://community.mp3tag.de/uploads/default/original/2X/8/8bf08c1bd6347a86477614260fc10fd271fbdde6.mta) (433 Bytes)

Thanks, just testing methods with a tag-tag and previewing:

```
1st will give:

050819 - FILENAME.mp3 >>>> 08-05-20T12:00:00Z 

2nd will give:

050819 - FILENAME.mp3 >>>> 19-08-2005T12:00:00Z

```

Sorry if I didn't highlight this well, but the 050819 is actually the 19th of 8(August), 2005

so not sure how to get it in YYYY-MM-DDThh:mm:ssZ or, 2005-08-19T12:00:00Z

As for the 01 - 2001-11-10.mp3 files, I previewed the third option and it seemed to work perfectly.

Thanks a lot, this would save me probably days of painful typing. 😲

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [March 1, 2014, 9:41pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/4 "2014-03-01T21:41:44Z")

</div>

Yeah first action should work on years 2000 to 2029 or 1900 to 1929 lol but it doesn't.

Sorry to fix that use:  
$regexp(%\_FILENAME%,^(\d\d)(\d\d)(\d\d).+,20$1-$2-$3T12:00:00Z)

---

<div class="post-metadata">

**Author:** ![madramadra](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@madramadra](https://community.mp3tag.de/u/madramadra)\
**Post date:** [March 1, 2014, 10:47pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/5 "2014-03-01T22:47:11Z")

</div>

This is amazing. I'm really pushing it now, but this is the last thing I will ever need. One more string to fix the date but this time the filename is:

1. ATT 30.01.13
2. ATT 31.01.13
3. ATT 01.02.13

By the way, I was examining the string you gave me to fix 01 - 2001-11-10.mp3, which worked great, to try figure out what string to make for 15. ATT 01.02.13 as I thought I should be able to figure it out, as the only difference is the 15 **.**  **ATT** 01 **.** 02 **.** 13 but I can't really do it. I was looking at [https://docs.mp3tag.de/actions/replace-regexp](https://docs.mp3tag.de/actions/replace-regexp) to figure out how to do this but I'm really bad at this stuff. I could make out that \s-\s corresponds to ' - ' but was not sure what the **,.+?** was supposed to mean.

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [March 1, 2014, 11:14pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/6 "2014-03-01T23:14:40Z")

</div>

> [@madmadra](#):
>
> 1. ATT 30.01.13
> 2. ATT 31.01.13
> 3. ATT 01.02.13
> 
> By the way, I was examining the string you gave me to fix 01 - 2001-11-10.mp3, which worked great, to try figure out what string to make for 15. ATT 01.02.13 as I thought I should be able to figure it out, as the only difference is the 15 **.**  **ATT** 01 **.** 02 **.** 13 but I can't really do it. I was looking at [https://docs.mp3tag.de/actions/replace-regexp](https://docs.mp3tag.de/actions/replace-regexp) to figure out how to do this but I'm really bad at this stuff. I could make out that \s-\s corresponds to ' - ' but was not sure what the **,.+?** was supposed to mean.

This is similar to the 2nd option I gave in my 1st post. Only I had a ^ at the start of that regexp. This anchors whatever the remaining regexp is from the very start of th text string.

For this one you can modify your 060210 - FILENAME.mp3 fix by changing:

$regexp(%\_FILENAME%,^(\d\d)(\d\d)(\d\d).+,$3-$2-20$1T12:00:00Z)

to

$regexp(%\_FILENAME%,.+\sATT\s(\d\d)\.(\d\d)\.(\d\d)$,20$3-$2-$1T12:00:00Z)

The . matches any character at all and the + is a quantifier which means any number from 1 to infinity. If you used \* it would be 0 to infinity. The \sATT\s matches one whitespace char then ATT then \s again. If you wanted to get fancy you could place (?-i) anywhere in the regexp and it will only match with case sensitivity. The . matches the . char specifically. Then $ anchors to the end of the text string so this will not work for '13. ATT 30.01.13 something other text here'

Different strings to find mean different regular expressions of course and the more you practice the better you get. There are many places to find good info:  
[http://www.regular-expressions.info/tutorial.html](http://www.regular-expressions.info/tutorial.html)  
[http://www.proftpd.org/docs/howto/Regex.html](http://www.proftpd.org/docs/howto/Regex.html)

I just goggled 'reg expression explained' and loads came up.

and to test your reg exp:  
[http://regexpal.com/](http://regexpal.com/)

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [December 13, 2020, 2:37pm UTC](https://community.mp3tag.de/t/release-time-and-date-from-filename/15549/7 "2020-12-13T14:37:23Z")

</div>

Closed on December 13, 2020, 2:37pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
