# Actions: from filename to genre and date format regular expression

**URL:** https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314
**Category:** Support
**Created:** [October 19, 2015, 6:10pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314 "2015-10-19T18:10:19Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 19, 2015, 6:10pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/1 "2015-10-19T18:10:19Z")

</div>

Hi! I have two moments for making my music sorting ideal! Can you help me, please?

1. I have the collection with filenames like:  
Artist 1 - track 1#genre1.mp3  
Artist 2 - track 1#genre2.mp3  
Artist 3 - track 1#genre3.mp3  
etc

can I use actions to replace all these genres to "Genre" tag (and after it delete "#..." part from filename)?

1. I have "release time" tags like:  
2015-08-06  
2015-03-05  
09-18-2014  
03/23/2015

I use replace in actions to make it all with "-" instead "/"  
After it I'm trying replace with regular expression a{2}-b{2}-c{4} -\> c{4}-a{2}-b{2} to move year to beginning, but it doesn't work. What is right expression for it?

Also sometimes release time is somehow like: [http://i.imgur.com/F7mHfo1.png](http://i.imgur.com/F7mHfo1.png) or longer  
So it will be perfect ot leave only first 10 characters in this tag.

Will be happy if someone help me with this, thanks!

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 19, 2015, 6:23pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/2 "2015-10-19T18:23:48Z")

</div>

> [@Kitin](#):
>
> ...
> 
> can I use actions to replace all these genres to "Genre" tag (and after it delete "#..." part from filename)?
> 
> 1. I have "release time" tags like:  
> 2015-08-06  
> 2015-03-05  
> 09-18-2014  
> 03/23/2015
> 
> I use replace in actions to make it all with "-" instead "/"  
> After it I'm trying replace with regular expression a{2}-b{2}-c{4} -\> c{4}-a{2}-b{2} to move year to beginning, but it doesn't work. What is right expression for it?  
> ...

The action of the type "Guess values" works just like the function Convert\>Filename-Tag, so you can enter the same pattern e.g.:  
Artist 1 - track 1#genre1.mp3  
%artist% - %title%#%genre%  
or if you want to get only the GENRE:  
%dummy%#%genre%

Swapping different parts of a string for the date should be:  
Search string: (\d+)-(\d+)-(\d+)  
Replace string: $3-$1-$2

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 19, 2015, 7:08pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/3 "2015-10-19T19:08:50Z")

</div>

Hi ohrenkino, thanks for quick reply! But I have two problems with your advices:

1. Guess values works good! But I have .mp3 in genre too - [http://i.imgur.com/qFgziEk.png](http://i.imgur.com/qFgziEk.png)  
How can I remove ".mp3" from genre and can I delete #genre from filename after step 1?

2. This expression shuffle all my dates like [http://i.imgur.com/6xlx3uc.png](http://i.imgur.com/6xlx3uc.png)  
So I need something to format "aa-bb-cccc -\> cccc-aa-bb" for keeping "aaaa-\*" dates as they are  
and make and keep it from only first 10 symbols because of sometimes it's like "2015-08-18\\2015-08-18\\2015-08-18", so maybe first cut it...

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 19, 2015, 7:21pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/4 "2015-10-19T19:21:47Z")

</div>

> [@Kitin](#):
>
> ...
> 
> 1. Guess values works good! But I have .mp3 in genre too - ...
> 
> How can I remove ".mp3" from genre and can I delete #genre from filename after step 1?

My advice should not cause any trouble but the supplied data should.  
Anyway:  
To remove ".mp3" from Genre (how did that come about?) use a simple replace: search for ".mp3" and replace it with nothing.  
To get a clean filename I would suggest that you rewrite the filename with Convert\>Tag-Filename as the data is now much better stored in the fields.

> [@](#):
>
> 1. This expression shuffle all my dates like [http://i.imgur.com/6xlx3uc.png](http://i.imgur.com/6xlx3uc.png)  
> So I need something to format "aa-bb-cccc -\> cccc-aa-bb" for keeping "aaaa-\*" dates as they are  
> and make and keep it from only first 10 symbols because of sometimes it's like "2015-08-18\\2015-08-18\\2015-08-18", so maybe first cut it...

Yes it does. It is not intelligent.  
You could filter for the files that have no 4-digit-data at the front:  
NOT %field% MATCHES ^\d\d\d\d  
(I do not know where you store the date as there are only the fields YEAR and RELEASETIME - but these have a completely different standard.  
You then transform all the dates to a uniform pattern.

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 20, 2015, 8:23am UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/5 "2015-10-20T08:23:28Z")

</div>

> [@](#):
>
> To remove ".mp3" from Genre (how did that come about?) use a simple replace: search for ".mp3" and replace it with nothing.  
> To get a clean filename I would suggest that you rewrite the filename with Convert\>Tag-Filename as the data is now much better stored in the fields.

Oh, yes, exactly! Thanks!

> [@](#):
>
> You could filter for the files that have no 4-digit-data at the front:  
> NOT %field% MATCHES ^\d\d\d\d

Oh, yes, it's work too, thanks!  
Sadly, that it can't be automated with Actions, I thought that replacement with expressions like xxxx-yy-zz -\> yy-zz-xxxx possible..  
And actions to cut string to first 10 symbols not possible too?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 20, 2015, 8:50am UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/6 "2015-10-20T08:50:25Z")

</div>

> [@Kitin](#):
>
> Oh, yes, exactly! Thanks!
> 
> Oh, yes, it's work too, thanks!  
> Sadly, that it can't be automated with Actions, I thought that replacement with expressions like xxxx-yy-zz -\> yy-zz-xxxx possible..  
> And actions to cut string to first 10 symbols not possible too?

If the dates should always be turned around (which I would not recommend as you then get all tracks from a particular month or day sorted togehter) then of course you can set it like that.  
To define one chunk, enclose it in parenthesis, e.g. (\d\d\d\d). All the bits in parenthesis can then be adresse with $1, $2, $3 etc counting the parenthesis from left to right.

The date that you showed with the \\ looks to me like a multi-value-field. You either have to merge the duplicate fields first with a different separator than \\ (there is an action for that) or use "Format value" with the $meta() function to address a particular field of the duplicates.

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 20, 2015, 12:30pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/7 "2015-10-20T12:30:31Z")

</div>

> [@](#):
>
> If the dates should always be turned around (which I would not recommend as you then get all tracks from a particular month or day sorted togehter) then of course you can set it like that.  
> To define one chunk, enclose it in parenthesis, e.g. (\d\d\d\d). All the bits in parenthesis can then be adresse with $1, $2, $3 etc counting the parenthesis from left to right.
> 
> The date that you showed with the \\ looks to me like a multi-value-field. You either have to merge the duplicate fields first with a different separator than \\ (there is an action for that) or use "Format value" with the $meta() function to address a particular field of the duplicates.

Oh, really, I see!  
Fileds are really multi-valued, I get it from beatport app and sometimes it in format YYYY-MM-DD and sometimes MM-DD-YYYY (but at this moment always month going first) and sometimes multi-valued.  
So, after these actions I have date like this - [http://i.imgur.com/ufS6ZF1.png](http://i.imgur.com/ufS6ZF1.png)

It's good! But tell me once again please, how to cut merged tag? It has no permanent limit, can be dublicated 2,3,4 times, but I can't find something like \* (like "if any text next") in expressions to replace it..

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 20, 2015, 1:15pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/8 "2015-10-20T13:15:50Z")

</div>

> [@Kitin](#):
>
> ... tell me once again please, how to cut merged tag? It has no permanent limit, can be dublicated 2,3,4 times, but I can't find something like \* (like "if any text next") in expressions to replace it..

If you have a display like  
"2015-08-18\\2015-08-18\\2015-08-18"  
for a field e.g. DATE  
The create an action of the type "Merge duplicate fields"  
Field: DATE  
Separator:\_  
(underscore)  
After that action you have only one field DATE with the contents  
2015-08-18\_2015-08-18\_2015-08-18  
You can now $trimleft(10)  
that field in an action of the type "Format tag-field"

Of if you like a "Replace with regular expression" better  
Search string: \_.\*  
Replace string:  
(leave empty)  
(in your case it is the -- instead of the \_)

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 20, 2015, 2:02pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/9 "2015-10-20T14:02:40Z")

</div>

ohrenkino, works great! Thanks!! You helped make my collection of perfect! 🙂

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 22, 2015, 5:52pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/10 "2015-10-22T17:52:18Z")

</div>

Hi I cleaned my music collection with Mp3tag and now it's in excellent form, but..  
All tags that going from one program to another are staying right, except.. yes, this is realasetime.

I tried in MusicBee and Traktor.

Firslty I used format YYYY-MM-DD, than, by your (ohrenkino) advice from [here](https://community.mp3tag.de/t/16556/2) I tried YYYY-MM-DDThh:mm:ss but it's still has format YYYY/1/1 in Traktor end empty in MusicBee.  
If I use YYYY/MM/DD it's still YYYY/1/1/ in Traktor.

I didn't found any solutions more. Maybe have any ideas how to keep it everywhere?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 22, 2015, 6:00pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/11 "2015-10-22T18:00:31Z")

</div>

The problem could be:  
target program does not dispaly the field at all (looks like that in MusicBee).  
target program does not update the information.  
For Traktor there is this thread:  
[/t/13735/1](https://community.mp3tag.de/t/13735/1)  
It suggests that you right-click and check the consistency. Then the updated date should be shown.

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 22, 2015, 7:00pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/12 "2015-10-22T19:00:56Z")

</div>

ohrenkino, when I'm changing date in Mp3tag and looking in Traktor again - year is changing but other part - no, so I think dates udated but trouble with format or something

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 22, 2015, 7:05pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/13 "2015-10-22T19:05:48Z")

</div>

> [@Kitin](#):
>
> ohrenkino, when I'm changing date in Mp3tag and looking in Traktor again - year is changing but other part - no, so I think dates udated but trouble with format or something

The field YEAR has as only valid format a 4-digit-number.  
Some programs support also the field DATE which holds month and day.  
Some programs combine these 2 fields to one display, yet the data is stored in 2 fields.  
So, perhaps you have to fill the field DATE as well.

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 22, 2015, 8:01pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/14 "2015-10-22T20:01:56Z")

</div>

> [@ohrenkino](#):
>
> The field YEAR has as only valid format a 4-digit-number.  
> Some programs support also the field DATE which holds month and day.  
> Some programs combine these 2 fields to one display, yet the data is stored in 2 fields.  
> So, perhaps you have to fill the field DATE as well.

Oh, really! In Traktor it's "DATE"+"YEAR", so I need take current MM.DD.YYYY and replace parts MMDD and YYYY from my full date to two tags, yes?  
and one special with MusicBe...  
Maybe I can fill this in MusicBee then look somehow format that writen in file by it?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 23, 2015, 6:12am UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/15 "2015-10-23T06:12:47Z")

</div>

> [@Kitin](#):
>
> Oh, really! In Traktor it's "DATE"+"YEAR", so I need take current MM.DD.YYYY and replace parts MMDD and YYYY from my full date to two tags, yes? ...

Yes.  
Copy all of YEAR into date with an action of the type "Format value" for DATE.  
Format string: %year%

Then $cutright() or $cutleft() or Replace with regular expression to get the right amount of data into the field.

---

<div class="post-metadata">

### Author: ![kitin](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/k/e9c0ed/32.png) [@kitin](https://community.mp3tag.de/u/kitin)
#### Post date: [October 24, 2015, 10:09am UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/16 "2015-10-24T10:09:21Z")

</div>

> [@ohrenkino](#):
>
> Yes.  
> Copy all of YEAR into date with an action of the type "Format value" for DATE.  
> Format string: %year%
> 
> Then $cutright() or $cutleft() or Replace with regular expression to get the right amount of data into the field.

I copied data to 'year' and 'date' and replace them with reg exp to desired format, so it works great!  
Thanks!

Now I'm going to make custom field with same data and make it available in MusicBee (with it "Virtual tags") and asking this on MusicBee forum but they are not so quick as guys there 🙂

---

<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: [February 9, 2026, 12:25pm UTC](https://community.mp3tag.de/t/actions-from-filename-to-genre-and-date-format-regular-expression/17314/17 "2026-02-09T12:25:55Z")

</div>


