# Conditional copy part of tag to another tag

**URL:** https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812
**Category:** Support
**Created:** [June 17, 2013, 8:11am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812 "2013-06-17T08:11:08Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 17, 2013, 8:11am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/1 "2013-06-17T08:11:08Z")

</div>

Hi There,

I would like to make a action which copy a part of a tag to another tag:  
The conditions are: UPPERCASE words and words between ","

examples:  
%comment% = "LC 13357ATMOSPHERE ETHNIC POP, UP, adventure, RAPIDE, aventure,-----copyright bla bla"  
%comment% = "LC 14578TRADITIONAL FRENCH POP, MID, bewitching, sneaky, MEDIUM, ravisant,----copyright bla bla"

One may notice that this tag has English and French inside (UP,MID versus RAPIDE,MEDIUM)  
One may notice that this tag has %genre% %mood% info in it

The purpose after the retagging is that  
%mood% = adventure and %genre% = ETHNIC POP  
%mood% = bewitching sneaky and %genre% = FRENCH POP

Below is how the %comment% field looks in the lower left

> LC 15786 TRADITIONNAL FRENCH - TRADITIONNEL FRANCAIS, UP, bouncy, galoubet, tambourin, flute RAPIDE, sautillant, galoubet, tambourin, flute, --------------------------------------------- ----------------- Parispar copyright etc

I initially thought of tackling this one with

Cut first 8 charachters then cut last 240 charachters then put first 2 words in Genre then put all words not written in capital and between first 2 words completely written in capital in to %mood%.

What is the best way to handle this in a flexible way

Kind Regards  
Guy Forssman

---

<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 18, 2013, 4:00pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/2 "2013-06-18T16:00:28Z")

</div>

> [@ForSSOund](#):
>
> ...  
> examples:  
> %comment% = "LC 133547ATMOSPHERE ETHNIC POP,UP, adventure,RAPIDE, aventure,-----copyright"  
> %comment% = "LC 14578TRADITIONAL FRENCH POP,MID, bewitching, sneaky, MEDIUM, ravisant,----copyright"  
> ...  
> The purpose after the retagging is that  
> %mood% = adventure and %genre% = ETHNIC POP  
> %mood% = bewitching sneaky and %genre% = FRENCH  
> ..

I do not understand the examples.  
Why does ETHNIC POP stays the same whereas FRENCH POP becomes only FRENCH.

Also: some words in the list are spearated by others are separated by .

So far I cannot see any underlying pattern, sorry.

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 18, 2013, 4:06pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/3 "2013-06-18T16:06:06Z")

</div>

> [@ohrenkino](#):
>
> I do not understand the examples.  
> Why does ETHNIC POP stays the same whereas FRENCH POP becomes only FRENCH.
> 
> Also: some words in the list are spearated by others are separated by .
> 
> So far I cannot see any underlying pattern, sorry.

These are stupid error on my part. I manually wrote this over from another pc....I correct these now in the original post

Thank you for pointing this out to me  
Guy Forssman

---

<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 18, 2013, 4:52pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/4 "2013-06-18T16:52:37Z")

</div>

> [@ForSSOund](#):
>
> These are stupid error on my part. I manually wrote this over from another pc....I correct these now in the original post
> 
> Thank you for pointing this out to me  
> Guy Forssman

I take it that you are familiar with the fact that you can create an action group that works as some kind of batch job as it processes a set of actions in the given sequence.  
What I would do, is some kind of brute force approach as it produces copies of the data first and then strips it away again.  
First fill the MOOD field with the complete contents of the source field (that is comment, right?).  
Then fill the GENRE field with the complete contents of the source field.  
Then strip the leading number with a "Replace with regular expression": lc \d+\w+\b ((?-i)[A-Z].\*)  
Replace with $1.  
This should leave  
ETHNIC POP,UP, adventure,RAPIDE, aventure,-----copyright  
then format the field with a $left(%genre%,$sub($strchr(%genre%,','),1))  
this should leave ETHNIC POP.

to find the lowercase words use ._,((?-i)[a-z]_),  
and replace it with $1

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 19, 2013, 9:24am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/5 "2013-06-19T09:24:50Z")

</div>

> [@ohrenkino](#):
>
> I take it that you are familiar with the fact that you can create an action group that works as some kind of batch job as it processes a set of actions in the given sequence.  
> What I would do, is some kind of brute force approach as it produces copies of the data first and then strips it away again.  
> First fill the MOOD field with the complete contents of the source field (that is comment, right?).  
> Then fill the GENRE field with the complete contents of the source field.  
> Then strip the leading number with a "Replace with regular expression": lc \d+\w+\b ((?-i)[A-Z].\*)  
> Replace with $1.  
> This should leave  
> ETHNIC POP,UP, adventure,RAPIDE, aventure,-----copyright  
> then format the field with a $left(%genre%,$sub($strchr(%genre%,','),1))  
> this should leave ETHNIC POP.
> 
> to find the lowercase words use ._,((?-i)[a-z]_),  
> and replace it with $1

Thanks for this input..

At first I couldn't get it that your test didn't work but it seems that %comment% which is indeed the source field has everything already grouped with a return.

So I did a LC \d+\w+\b\r\n((?-i)[A-Z].\*) result= ETHNIC POP,UP, adventure,RAPIDE, aventure,-----copyright

Can You elaborate what the purpose of the (?-i) is?

Anyway thanks a lot already.  
Your example surely helped me to better understand regexp

Kind Regards  
Guy Forssman

---

<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 19, 2013, 10:28am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/6 "2013-06-19T10:28:07Z")

</div>

> [@ForSSOund](#):
>
> Can You elaborate what the purpose of the (?-i) is?

Ah - probably this is only for filters: it makes the statement case-sensitive ... and the filter is not.  
So perhaps the [A-Z] should already limit the selection to capitals. But apparently the (?-i) does not do any more harm than to make the statement a little more complicated to read.

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 19, 2013, 12:25pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/7 "2013-06-19T12:25:57Z")

</div>

> [@ohrenkino](#):
>
> Ah - probably this is only for filters: it makes the statement case-sensitive ... and the filter is not.  
> So perhaps the [A-Z] should already limit the selection to capitals. But apparently the (?-i) does not do any more harm than to make the statement a little more complicated to read.

Thanks for this information I'm very new to this regexp and searched for some online testers but hum which one agrees with mp3tag?  
Furthermore when I use ([a-z]_) it only seems to look in the first line.  
I tried with the \n\n([a-z]_) the only thing that changes is that the return symbols are removed.  
Also there is 1 word with a capital written ....Can one search for complete words?  
So I hope you can point me one more time in the right direction.

```
LC 13373
MILITARY, MILITAIRE,
MID, war, battle, strict, French, military drums,
MEDIUM, guerre, baitaille, strict, Francais, tambour,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

---

<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 19, 2013, 3:36pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/8 "2013-06-19T15:36:47Z")

</div>

QUOTE (ForSSOund @ Jun 19 2013, 16:25) \<{POST\_SNAPBACK}\>

... ([a-z]\*) it only seems to look in the first line. 

I tried with the \n\n([a-z]\*) the only thing that changes is that the return symbols are removed.  
Also there is 1 word with a capital written ....Can one search for complete words?  
So I hope you can point me one more time in the right direction.

```
LC 13373
MILITARY, MILITAIRE,
MID, war, battle, strict, French, military drums,
MEDIUM, guerre, baitaille, strict, Francais, tambour,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com<!--QuoteEnd--></div><!--QuoteEEnd-->

```

^._[A-Z]_ ([a-z]+),.\*  
will reduce the whole string to tambour  
as this is the "last" word that is in lower case followed by a comma.  
(The rest of the translation:  
Take any letters (._) from the beginning (^) followed by a sequence of upper case letters ([A-Z]_) and a blank and then pick out a set of lower case letters followed by a comma for the replace action and then the rest.  
Which word were you trying to get?

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 19, 2013, 6:07pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/9 "2013-06-19T18:07:46Z")

</div>

> [@ohrenkino](#):
>
> ^._[A-Z]_ ([a-z]+),.\*  
> will reduce the whole string to tambour  
> as this is the "last" word that is in lower case followed by a comma.  
> (The rest of the translation:  
> Take any letters (._) from the beginning (^) followed by a sequence of upper case letters ([A-Z]_) and a blank and then pick out a set of lower case letters followed by a comma for the replace action and then the rest.  
> Which word were you trying to get?

The end result should be ideally "war, battle, strict, French, military drums"  
The second line is the same but in French

Does regexp has the possibility to look only in the first or n line of this example for lowercase?  
I thought that \n\n([a-z]\*) would search for lowercase letters on the 3 th line..Obiviously I would have missed the F from French.

Thanks for helping me. When Finished I guess I can add this to the regexp examples as this is a more elaborate example and great for learning by example.

Guy Forssman

---

<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 19, 2013, 6:20pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/10 "2013-06-19T18:20:24Z")

</div>

This regexp  
^._\n._\n[A-Z]_, (._)\n._\n---._  
replaced with  
$1  
will produce

> [@ForSSOund](#):
>
> The end result should be ideally "war, battle, strict, French, military drums"

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 26, 2013, 12:31pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/11 "2013-06-26T12:31:46Z")

</div>

> [@ohrenkino](#):
>
> This regexp  
> ^._\n._\n[A-Z]_, (._)\n._\n---._  
> replaced with  
> $1  
> will produce

Hi Back from a 4 day trip to Sweden...

In fact thanks a lot for this, it works, but sometimes the %comment% field isn't properly formatted and thus the regexp doesn't work

^._\n_

> _start beginning line search every character till end of line_

  
_._\n 

> search every character till end of line

  
[A-Z]_, (._)\n

> All Capitals from Alphabet a , followed by everything else and put in group $1

I thought I change [A-Z]_, (._)\n to ([a-z]\*)\n just take every non capital helas that doesn't work either..

Your code works on the first example but not on the second

```
LC 13373
CLASSIC, CLASSIQUE,
SLOW, melancholy, lanscape, violin
LENT, melancolie, paysage, violon, 
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com 

LC 13373
UP, race, clarinet
RAPIDE, course, clarinette,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [June 27, 2013, 9:51am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/12 "2013-06-27T09:51:58Z")

</div>

This should work for both examples:  
^._\n[A-Z]+, (.+)\n._\n---.\*

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 27, 2013, 12:01pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/13 "2013-06-27T12:01:07Z")

</div>

Indeed this produced a lot more hits unfortunately it didn't solved every entry

Can somebody explain to me how to choose only the NON capital words?

I guess it's the part between ^._\n and \n._\n---.\* that should be changed.

What is wrong in my logic with ([a-z]\*)\n?

I could give another example with didn't work but I think it's better to search for a more flexible approach.

Anyway thanks a lot for the support  
Guy Forssman

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [June 27, 2013, 12:30pm UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/14 "2013-06-27T12:30:11Z")

</div>

If you just want all lower case words from this kind of text

```
LC 13373
UP, race, clarinet
RAPIDE, course, clarinette,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

it would give more results, also  
rights reserved  
publisher  
...

So please give a more exact description. Do you mean all lc words until the ----- line?

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [June 28, 2013, 7:07am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/15 "2013-06-28T07:07:12Z")

</div>

QUOTE (dano @ Jun 27 2013, 16:30) \<{POST\_SNAPBACK}\>

If you just want all lower case words from this kind of text

```
LC 13373
UP, race, clarinet
RAPIDE, course, clarinette,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

it would give more results, also  
rights reserved  
publisher  
...

So please give a more exact description. Do you mean all lc words until the ----- line?

Thanks for the reply I only want the lowercase words on the second line... so in this example it would be race, clarinet

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [June 28, 2013, 11:53am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/16 "2013-06-28T11:53:16Z")

</div>

Another try, this will find the first line with lower case words:  
^[^a-z]+[,]([a-z][a-z,]+)[\r\n]+.+?-------.+

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [August 27, 2013, 9:01am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/17 "2013-08-27T09:01:26Z")

</div>

> [@dano](#):
>
> Another try, this will find the first line with lower case words:  
> \[1\]+ ([a-z][a-z,]+)\n.+

Hi There,

it seems this regexp doesn't work for me..

I have used ^._\n[A-Z]+, (.+)\n._\n---.\*  
witch gave me following results for the 4 different cases below  
CASE1 =  
CASE2 =adventure  
CASE3 =bouncy, race, galoubet, tambourin, flute  
CASE4 =LC 13373 POP ROCK, CORPORATE, UP,adventure, walk, RAPIDE, aventure, marche, --------------------------------------------------------------------------- All rights reserved Producer publisher

Unfortunately there are a lot of wrongly formatted original tags like CASE4 to many to do this manually..  
Sometimes the mood is on the second line sometimes on the third It's however always non capital.

1 LC 13373

```
REGGAE
MID, 
MEDIUM,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

2 LC 13373

```
TECHNO ,
UP, adventure,
RAPIDE, aventure,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

3 LC 13373

```
TRADITIONNAL FRENCH - TRADITIONNEL FRANCAIS,
UP, bouncy, race, galoubet, tambourin, flute
RAPIDE, sautillant, course, galoubet, tambourin, flute,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

4 LC 13373

```
POP ROCK, CORPORATE,
UP,adventure, walk,
RAPIDE, aventure, marche,
---------------------------------------------------------------------------
All rights reserved
Producer publisher
PARSIPARLA
3 rue des Aulnes
03000 AVERMES
FRANCE
tel fax 33 (0)4 70 20 65 10
info@parsiparla.com
www.parsiparla.com

```

* * *

1. ^a-z

---

<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: [August 29, 2013, 7:27am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/18 "2013-08-29T07:27:37Z")

</div>

The expression  
^._\n[A-Z]+._\n([a-z][a-z]+._)\n._\n---.\*"

leads to  
UP, adventure, walk,

in case 4.  
Perhaps you can go on from there.

One footnote: it is very hard to get a testbed for these rather special cases - so the effort you would have to invest to do it manually is required by those who try to copy your environment. This may be a reason why you do not get that many answers.

So, you can test your regular expression with the filter and the MATCHES keyword.  
Enter the expression without any round brackets and see if you get any hits.  
Then try the expression with brackets in a single action on a single file.

---

<div class="post-metadata">

### Author: ![ForSSound](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@ForSSound](https://community.mp3tag.de/u/ForSSound)
#### Post date: [September 6, 2013, 5:39am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/19 "2013-09-06T05:39:21Z")

</div>

Hi There,

I would first thank everybody who has even just read this ..  
I must be doing something wrong because the latest 2 attempts didn't work for me.  
Here are 5 small [mp3 test files](https://drive.google.com/folderview?id=0B74nSQnUFHPDVzUxZmtpaG5LYXM&usp=sharing) with the different cases.  
How I applied the rule you can find in the screenshot

Thanks in advance  
Guy Forssman

![](https://community.mp3tag.de/uploads/default/original/2X/e/e673d7da11f6734d2de321345f0e17a41c6f5025.PNG)

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [September 6, 2013, 8:12am UTC](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812/20 "2013-09-06T08:12:22Z")

</div>

I've fixed my old regex:  
^[^a-z]+[,]([a-z][a-z,]+)[\r\n]+.+?-------.+

Also check [x] case-sensitive comparison

or try  
^.+?\n[A-Z]+[,]+([a-z][a-z,]+).+?----------.+

[Next page](https://community.mp3tag.de/t/conditional-copy-part-of-tag-to-another-tag/14812.md?page=2)
