# Moving part of TITLE to GENRE

**URL:** https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859
**Category:** Support
**Created:** [April 27, 2015, 6:50pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859 "2015-04-27T18:50:27Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [April 27, 2015, 6:50pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/1 "2015-04-27T18:50:27Z")

</div>

Hello

I would like to know, if it is possible to create an action group that would do this:

1] look at the end of TITLE tag  
2] if there is a "##something" or "## something" or "0000", move it to the beginning of GENRE tag  
3] look again at the end of TITLE tag  
4] if there is a "##something" or "## something", move it to the beginning of GENRE tag; with the addition of two pauses after it  
5] stop looking as soon as the end of the title tag runs out of the "##" indicator  
6] rearrange numerically / alphabetically the GENRE tag  
7] remove repeated stuff

Examples

```
TITLE tag: Make Me... Make You! {2012 Mix} [MEE] ##55 ## 02 ##03 ##01 ##VILLAGE ## CITY ##77 ##ACTION ## BATTLE ##ZZZZZZZZZ ## DESERT ##66  
[is split into]
TITLE tag: Make Me... Make You! {2012 Mix} [MEE]
GENRE tag: ##01 ##02 ##03 ##ACTION ##BATTLE ##CITY ##DESERT ###VILLAGE #ZZZZZZZZZ ##55 ##66 ##77

TITLE tag: Make Me... Make You! (Instrumental) {DJ XXX Remix} 0000  
[is split into]
TITLE tag: Make Me... Make You! (Instrumental) {DJ XXX Remix}
GENRE tag: 0000

TITLE tag: Make Me... Make You; PART 2 {Live 2000}##77 ## 33 ## 66 ## 55## 44
[is split into]
TITLE tag: Make Me... Make You; PART 2 {Live 2000}
GENRE tag: ##33 ##44 ##55 ##66 ##77

TITLE tag: Make Me... Make You; PART 3## 33 ## 66 ##33 ##33 ## 66
[is split into]
TITLE tag: Make Me... Make You; PART 3
GENRE tag: ##33 ##66

```

So please note that the there could be a total chaos, but the "##" / "## " indicates always a new separate value, and the must-be-order is:  
numbers from 01 to 49 \>\>\> words \>\>\> numbers from 50 to 99

---

<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: [April 28, 2015, 3:41am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/2 "2015-04-28T03:41:16Z")

</div>

> [@zerow](#):
>
> Hello
> 
> I would like to know, if it is possible to create an action group that would do this:
> 
> 1] look at the end of TITLE tag  
> 2] if there is a "##something" or "## something" or "0000", move it to the beginning of GENRE tag  
> 3] look again at the end of TITLE tag  
> 4] if there is a "##something" or "## something", move it to the beginning of GENRE tag; with the addition of two pauses after it  
> 5] stop looking as soon as the end of the title tag runs out of the "##" indicator  
> 6] rearrange numerically / alphabetically the GENRE tag  
> 7] remove repeated stuff  
> ...

I think that the first 5 steps can be dealt with like this:  
Copy all of the TITLE to GENRE  
Apply an action of the type "Replace with regular expression to GENRE  
Search string: ^(._) (#._)$  
Replace string: $2  
This removes the text in front of the first ##.  
Do the same with TITLE only with  
Replace string: $1  
Now you have all the raw data in the fields. Now have fun with the sorting.

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [May 6, 2015, 9:54am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/3 "2015-05-06T09:54:40Z")

</div>

> [@ohrenkino](#):
>
> I think that the first 5 steps can be dealt with like this:  
> Copy all of the TITLE to GENRE  
> Apply an action of the type "Replace with regular expression to GENRE  
> Search string: ^(._) (#._)$  
> Replace string: $2  
> This removes the text in front of the first ##.

Unfortunately, it removes everything placed before the last "##"

> [@ohrenkino](#):
>
> Do the same with TITLE only with  
> Replace string: $1

That seems to do nothing

> [@ohrenkino](#):
>
> Now you have all the raw data in the fields. Now have fun with the sorting.

The sorting could be done quite easily [although in long steps]

A] Remove all the "##" [which leaves numbers in format \>\>00\<\<]  
B] Replace words with numbers [in format \>\>00\<\<]  
C] Leave only one instance of each number [because I need to remove the doubled and tripled ones]  
D] Rearrange numbers in order [sort them out]  
E] Put two pauses after each number  
F] Change [specified] numbers back to words  
G] Put back "##" in front of the numbers  
H] Put back "##" in front of the words  
I] Remove unnecessary pauses

So, I would like to ask for codes for point C, D and E

Also, I'm afraid that step D could mess things up [because it could possibly turn for example "99 01" into "0199" instead of "01 99"]

And please note, that all the time I'm using the "##" [double hashtag] as a marker and not "#" [single one]; becasue I already use a single # chacacter [in TITLE tag for different purposes]

---

<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: [May 6, 2015, 10:11am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/4 "2015-05-06T10:11:00Z")

</div>

> [@zerow](#):
>
> Unfortunately, it removes everything placed before the last "##"  
> ...

Shame this, really. Sorry.  
If it is always the ## that separates TITLE from GENRE, you could apply an action of the type  
"Guess value (Import tag field)" for TITLE  
Guessing pattern: %title% #%genre%

you loose the leading #.

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [May 6, 2015, 1:54pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/5 "2015-05-06T13:54:44Z")

</div>

> [@ohrenkino](#):
>
> [...]  
> If it is always the ## that separates TITLE from GENRE, you could apply an action of the type  
> "Guess value (Import tag field)" for TITLE  
> Guessing pattern: %title% #%genre%
> 
> you loose the leading #.

I did some test and thinking about that whole guessing pattern and came with solution with workaround / fail-safes

But I still don't know how to simply sort numbers in order and put two pauses after each number [step D and E]

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 16, 2015, 11:14am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/6 "2015-06-16T11:14:35Z")

</div>

So, does any one now how to sort two digit numbers in an ascending matter?

For example:

```
BEFORE
01 10 22 21 33 99
AFTER
01 10 21 22 33 99

BEFORE
99 01 10 22 21 33
AFTER
01 10 21 22 33 99

BEFORE
10 99 01 22 33 21
AFTER
01 10 21 22 33 99
```

---

<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: [June 16, 2015, 4:07pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/7 "2015-06-16T16:07:48Z")

</div>

> [@zerow](#):
>
> So, does any one now how to sort two digit numbers in an ascending matter?

If you are looking for a built in function: hard luck, there is none.  
Also, you cannot use any nested loops to treat a string.  
You could export the field to a text file,  
use the command shell function "sort"  
let "sort" create an output file that you then import back into the tag.

To see what "sort" can do, open a command shell window and type in: help sort

AFAIU sort needs one sort item per line

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 16, 2015, 5:56pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/8 "2015-06-16T17:56:13Z")

</div>

> [@zerow](#):
>
> So, does any one now how to sort two digit numbers in an ascending matter? ...

Mp3tag has no sort function to be used within formatstring.

You may have a look there ...  
[Feature request: Import tags from clipboard](https://community.mp3tag.de/t/7196/17)  
... maybe you can adapt it to your needs.

DD.20150616.2156.CEST

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 17, 2015, 12:03pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/9 "2015-06-17T12:03:29Z")

</div>

> [@zerow](#):
>
> So, does any one now how to sort two digit numbers in an ascending matter?

> [@ohrenkino](#):
>
> You could export the field to a text file,  
> use the command shell function "sort"  
> let "sort" create an output file that you then import back into the tag.

Unfortunately that's just to much effort / steps; beause I will need this to be done on 18000 files

And after a couple of weeks / months, I will repeat the whole operation, with even more files

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 17, 2015, 12:31pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/10 "2015-06-17T12:31:06Z")

</div>

> [@DetlevD](#):
>
> Mp3tag has no sort function to be used within formatstring.
> 
> You may have a look there ...  
> [Feature request: Import tags from clipboard](https://community.mp3tag.de/t/7196/17)  
> ... maybe you can adapt it to your needs.
> 
> DD.20150616.2156.CEST

That looks adaptable to my needs

But, aside from possible re-designing the system, it would still require physically going [switching] to another window with different program and doing there some clicking? If yes then I will have to do this sorting manually

As long as I will do it on a big set of files and have all the data in the same format [with numbers], I could to this quite efficient; aside from course occasionally missing some errors, which can be possibly taken care of during the next evaluation

And the bigger the set the better [to some point I imagine...], because it will be somewhat easy to spot an error like this

```
##01 ##02 ##03 ##44 ##59 ##99 ##90

```

if it is between tens of looking the same correct ones

```
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##90 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##60 ##99
##01 ##02 ##03 ##44 ##59 ##99 ##90
##01 ##02 ##03 ##44 ##59 ##99 ##90
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99
##02 ##03 ##44 ##59 ##60 ##90 ##99

```

I just need enough correct cases, so that errors will "pop out" while scrolling the view down

[I've already tried to the the first evaluation and in mixed system, with words between bumbers, it looks like chaos; I just stopped after first few screens]

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 17, 2015, 2:15pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/11 "2015-06-17T14:15:28Z")

</div>

> [@zerow](#):
>
> That looks adaptable to my needs ... But, ... it looks like chaos ...

zerow, I do not understand what you are telling me, ...  
therefore I made an example action group script ...  
to demonstrate how to sort number strings in the range from '01' to '99'.

Begin Action Group **Test2015#20150617.Example.Sort.01to99** 

Action #1  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **LIST\_CURRENT**  
_Formatstring:_ **'04|21|69|99|17|01|38|78'**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **LIST\_ORDERED**  
_Formatstring:_ **'01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|  
21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|  
41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|  
61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|  
81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99'**

 

Action #3  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **LIST\_RESULT**  
_Formatstring:_ **$regexp($regexp($regexp(%LIST\_ORDERED%,$regexp(%LIST\_ORDERED%,'(?\>('%LIST\_CURRENT%'))',),),'|+','|'),'|$',)**

 

End Action Group **Test2015#20150617.Example.Sort.01to99** (3 Actions)

 

... which gives ...  
LIST\_RESULT = 01|04|17|21|38|69|78|99

 

[Test2015\_20150617.Example.Sort.01to99.mta](https://community.mp3tag.de/uploads/default/original/2X/3/336b2a02ca3f2a3093e99b13deeb8b86be5c0722.mta) (535 Bytes)

 

DD.20150617.1836.CEST

 

Note: Regular expression has been changed ... see there ...  
[Moving part of TITLE to GENRE](https://community.mp3tag.de/t/16859/20)

 

DD.20150626.1116.CEST

 

[Test2015\_20150617.Example.Sort.01to99.mta](https://community.mp3tag.de/uploads/default/original/2X/3/336b2a02ca3f2a3093e99b13deeb8b86be5c0722.mta) (535 Bytes)

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 21, 2015, 4:10pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/12 "2015-06-21T16:10:28Z")

</div>

> [@DetlevD](#):
>
> [...] I made an example action group script ...  
> to demonstrate how to sort number strings in the range from '01' to '99'.
> 
> Begin Action Group **Test2015#20150617.Example.Sort.01to99** 
> 
> Action #1  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **LIST\_CURRENT**  
> _Formatstring:_ **'04|21|69|99|17|01|38|78'**
> 
>  
> 
> Action #2  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **LIST\_ORDERED**  
> _Formatstring:_ **'01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|  
> 21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|  
> 41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|  
> 61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|  
> 81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99'**
> 
>  
> 
> Action #3  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **LIST\_RESULT**  
> _Formatstring:_ **$regexp($regexp($regexp(%LIST\_ORDERED%,$regexp(%LIST\_ORDERED%,'(?\>('%LIST\_CURRENT%'))',),),'|+','|'),'|$',)**
> 
>  
> 
> End Action Group **Test2015#20150617.Example.Sort.01to99** (3 Actions)
> 
>  
> 
> ... which gives ...  
> LIST\_RESULT = 01|04|17|21|38|69|78|99
> 
>  
> 
> [Test2015\_20150617.Example.Sort.01to99.mta](https://community.mp3tag.de/uploads/default/original/2X/3/336b2a02ca3f2a3093e99b13deeb8b86be5c0722.mta) (535 Bytes)
> 
>  
> 
> DD.20150617.1836.CEST

I have run this action group on a field with value

```
04|21|69|99|17|01|38|78

```

And it stayed the same; nothing changed

Aside from that, my question is: is this is going to work only, if I predefine [write down to that action group] a separate entry [action] for every possible combination of errors?  
For example a common mistake will be

```
##01 ##01 ##02

```

But also there can be something like

```
##01 ##01 ##01 ##02
##01 ##99 ##01 ##02
##99 ##01 ##02
##99 ##01 ##99 ##02
##02 ##01 ##02

```

Putting all possible cases is just impossible for a human being

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 22, 2015, 5:43am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/13 "2015-06-22T05:43:49Z")

</div>

> [@zerow](#):
>
> I have run this action group on a field with value
> 
> ```
> 04|21|69|99|17|01|38|78
> 
> ```
> 
> And it stayed the same; nothing changed ...

Please try again.  
At my side there is no problem to get ...  
LIST\_OUT=01|04|17|21|38|69|78|99  
from ...  
LIST\_IN=04|21|69|99|17|01|38|78  
LIST\_IN=04|21|69|99|17|17|01|38|78|21  
LIST\_IN=78|04|04|04|21|69|99|99|17|17|01|38|78|21|78

DD.20150622.0943.CEST

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 24, 2015, 4:03pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/14 "2015-06-24T16:03:32Z")

</div>

> [@DetlevD](#):
>
> Please try again.  
> [...]

I've read the code and thought about what is suppose to happen and finally understood it [but not how it is happening]; and so I see that it works now

And now I have the right tool and the knowledge how to adapt it to my needs. I've already made some changes in it. But to make the whole operation simpler [with less steps, which will come in handy in the future in case of making any changes to the naming structure] I've tried to replace the

```
|sign used by you with the indicators used by me, in form of
##

```

And with such change, the code stops to work. Is there some problem with using hashtags? Or a change like that shouldn't be a problem and I just messed up something?

Also: why does the first number [in my unsorted string of numbers] can't have the indicator? I have putted it to the front of LIST\_ORDERED, but it didn't help

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 24, 2015, 4:20pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/15 "2015-06-24T16:20:08Z")

</div>

> [@zerow](#):
>
> ... And now I have the right tool and the knowledge how to adapt it to my needs. I've already made some changes in it. ... And with such change, the code stops to work. ...

Note: The pipe symbol or vertical bar "|" has the meaning of "alternation" resp. "or", ...  
and is used within the regular expression to separate alternative values.  
'01' or '02' or '03' ==\> '01|02|03'  
See also:  
[http://www.regular-expressions.info/alternation.html](http://www.regular-expressions.info/alternation.html)

I don't know for sure, but you may try for your case ...  
'##01|##02|##03'  
... or ...  
'##(01|02|03)'

DD.20150624.2020.CEST

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 24, 2015, 7:51pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/16 "2015-06-24T19:51:44Z")

</div>

> [@DetlevD](#):
>
> Note: The pipe symbol or vertical bar "|" has the meaning of "alternation" resp. "or", ...  
> and is used within the regular expression to separate alternative values.
> 
> [...]
> 
> I don't know for sure, but you may try for your case ...  
> '##01|##02|##03'  
> ... or ...  
> '##(01|02|03)'
> 
> DD.20150624.2020.CEST

Those two suggestions didn't work, but I've managed in some other way

[Here is](http://sendfile.pl/pokaz/403535---s4Cw.html) my action group:

```
1] Guess values %GENRE%: ##%GENRE%

2] Replace "GENRE": "##" -> |

3] Replace "GENRE": " " -> ""

4] Format value "GENRE_ORDER": '00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|2
5|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|TRIBAL
|
UNDERWATER|VILLAGE|WASTELAND|WATER|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|
7
5|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|9X'

5] Format value "GENRE": $regexp($regexp($regexp(%GENRE_ORDER%,$regexp(%GENRE_ORDER%,'(?>('%GENRE%'))',),),'\|+','|'),'\|$',)

6] Replace "GENRE": "|" -> " ##"

7] Format value "GENRE": $trim(%GENRE%)

8] Format value "GENRE": ##%GENRE%

```

It works if run it on a GENRE tag that has values in format

```
##00 ##00 ##AAAAAAA ##00 ##BBB

```

[two hastags + two digit number or predifined capitalized word + two pauses]

But:

A] What is the code for making any number of spaces into only two spaces, including in the middle of a tag? Or what is the code for making 3 or more spaces into two spaces? Right now I use [before I run this action group that we are speaking of in this post] many many [just for sure] instances of

```
Replace "GENRE": " " -> " "

```

for achieving my format

B] This code has a big issue. If you run it on

```
##9X ##WATER ##00 ##UNDERWATER ##50 ##VILLAGE

```

it will give you a proper

```
##00 ##UNDERWATER ##VILLAGE ##WATER ##50 ##9X

```

But if you run it on

```
##9X ##WATER ##00 ##50 ##VILLAGE

```

you will get a reasult with a wrongly doubled value

```
##00 ##WATER ##VILLAGE ##WATER ##50 ##9X

```

just because on the list of words [within this list of those 00-99 numbers] there is "UNDER **WATER**" and "WATER". I could work around this problem by temporary changing words to some additional numbers / codes [like X00, X01, X03], but as the word list is a work in progress, I would rather not have to [remember to make additional changes in this GENRE rearranging action group every time I will add new words or change the old ones]

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 25, 2015, 3:09am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/17 "2015-06-25T03:09:11Z")

</div>

> [@zerow](#):
>
> ... What is the code for making any number of spaces into only two spaces, including in the middle of a tag? ...

**TEST\_SPACES \<== 'xx xx xx xx xx xx xx xx xx xx' TEST\_RESULT \<== $regexp(%TEST\_SPACES%,' +','') TEST\_RESULT = 'xx xx xx xx xx xx xx xx xx xx'**

DD.20150625.0709.CEST

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 25, 2015, 3:50am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/18 "2015-06-25T03:50:36Z")

</div>

> [@zerow](#):
>
> ... This code has a big issue. ... if you run it on
> 
> `##9X ##WATER ##00 ##50 ##VILLAGE`  
> you will get a reasult with a wrongly doubled value
> 
> `##00 ##WATER ##VILLAGE ##WATER ##50 ##9X`  
> just because on the list of words [within this list of those 00-99 numbers] there is "UNDERWATER" and "WATER". ...

I assume a failure in your test environment, because it works as designed.

```auto
LIST_IN <== '01|09|WATER|04|VILLAGE|06|UNDERWATER|08|03|02|10'

LIST_SORT <== '01|02|03|VILLAGE|04|05|06|WATER|07|08|UNDERWATER|09|10'
LIST_OUT <== $regexp(
               $regexp(
                $regexp(%LIST_SORT%,
                 $regexp(%LIST_SORT%,'(?>('%LIST_IN%'))',)
                ,)
               ,'\|+','|')
              ,'\|$',)

LIST OUT = 01|02|03|VILLAGE|04|06|WATER|08|UNDERWATER|09|10

```

DD.20150625.0757.CEST

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [June 25, 2015, 5:09pm UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/19 "2015-06-25T17:09:14Z")

</div>

> [@DetlevD](#):
>
> **TEST\_SPACES \<== 'xx xx xx xx xx xx xx xx xx xx'TEST\_RESULT \<== $regexp(%TEST\_SPACES%,' +','')TEST\_RESULT = 'xx xx xx xx xx xx xx xx xx xx'**
> 
> DD.20150625.0709.CEST

Yes, that takes makes my double spaced format with just one action, for any number od spaces  
Thank you for helping me in getting rid of

```
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "
Replace "GENRE": " " -> " "

```

Which removed only up to 11 unnecessary spaces and also changed one into two

> [@zerow](#):
>
> [...]  
> This code has a big issue. If you run it on
> 
> ```
> ##9X ##WATER ##00 ##UNDERWATER ##50 ##VILLAGE
> 
> ```
> 
> it will give you a proper
> 
> ```
> ##00 ##UNDERWATER ##VILLAGE ##WATER ##50 ##9X
> 
> ```
> 
> But if you run it on
> 
> ```
> ##9X ##WATER ##00 ##50 ##VILLAGE
> 
> ```
> 
> you will get a reasult with a wrongly doubled value
> 
> ```
> ##00 ##WATER ##VILLAGE ##WATER ##50 ##9X
> 
> ```
> 
> just because on the list of words [within this list of those 00-99 numbers] there is "UNDER **WATER**" and "WATER".

> [@DetlevD](#):
>
> I assume a failure in your test environment, because it works as designed. DD.20150625.0757.CEST

So what you are saying is, I have to do a workaround: change all the words [or at least cases like WATER / UNDERWATER] to unique set of characters; and run the code in version including those temporary unique changes in the order list?

Because double WATER is immanent and is not to be viewed as an error?

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [June 26, 2015, 7:10am UTC](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859/20 "2015-06-26T07:10:02Z")

</div>

> [@zerow](#):
>
> ... So what you are saying is ...

Well, there is a problem within the regular expression, which has not be shown, when using numerical string values in the range from '01' to '99', but might coming up for strings like '101' .  
Other text strings like 'WATER' and 'WATERFALL' will show the same problem.  
There is no problem for 'WATER' and 'UNDERWATER'.

The failure was in the regular expression, which has evaluated the leading string fragment but not an entire word. Following example now evaluates a word for the comparing.

```auto
LIST_IN <== '111|101|01|WATER|WATERFALL|04|VILLAGE|06|UNDERWATER|03|02|10|11'

LIST_SORT <== '01|02|03|04|05|06|07|08|09|10|11|101|111|UNDERWATER|VILLAGE|WATER|WATERFALL'

LIST_OUT <== $regexp(

               $regexp(
                $regexp(%LIST_SORT%,
                        $regexp(%LIST_SORT%,'(?>\b('%LIST_IN%')\b)',)
                        ,)
                ,'\|+','|')
               ,'\|$',)

LIST OUT = 01|02|03|04|06|10|11|101|111|UNDERWATER|VILLAGE|WATER|WATERFALL

```

DD.20150626.1123.CEST

[Next page](https://community.mp3tag.de/t/moving-part-of-title-to-genre/16859.md?page=2)
