# Changing Firstnam Lastname to Lastname, Fisrtname Problem

**URL:** https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423
**Category:** Support
**Created:** [December 3, 2015, 10:04pm UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423 "2015-12-03T22:04:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tagmusing](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tagmusing](https://community.mp3tag.de/u/tagmusing)
#### Post date: [December 3, 2015, 10:04pm UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/1 "2015-12-03T22:04:30Z")

</div>

As the title says, I have a problem regarding the swapping of firstname lastname. If it is just one set, I can do it with a regex. But having a list (FN LN; FN LN; FN LN;...), I don't get the propper result. I tried a few examples from the forum and ended with:

```
[#0]
T=5
F=COMPOSERSORT
1=%COMPOSER%

[#1]
T=2
F=COMPOSERSORT
1=; 
2=;
3=0|0

[#2]
T=4
F=COMPOSERSORT
1=([^;]+)\\\\s([^;]+)
2= $2, $1
3=0which leaves me with the right result, only I still have to cut away a leading extra space.

```

But my problem is, that I need it all in one action, not three. What I wood like to have is something like that:

```
T=5
F=COMPOSERSORT
1=$if2(%composersort%,$regexp($regexp(%composer%,(.*?) (\\\\w*)(', '|$),$2', '$1; ),; $,))But working with a list, and not just one name. As I only want to change the field, if it not filled, I can't use the long example, as it would make changes regardless if it is empty or not.

```

Has anyone of you a good idea?

---

<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: [December 4, 2015, 3:50am UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/2 "2015-12-04T03:50:14Z")

</div>

> [@tagmusing](#):
>
> ... I have a problem regarding the swapping of firstname lastname. ... Has anyone of you a good idea?

See there ...  
[Composersort mit mehreren Personen](https://community.mp3tag.de/t/11298/5)  
Does it work for you?

DD.20151204.0550.CET

---

<div class="post-metadata">

### Author: ![tagmusing](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tagmusing](https://community.mp3tag.de/u/tagmusing)
#### Post date: [December 4, 2015, 8:32am UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/3 "2015-12-04T08:32:51Z")

</div>

Thank You Detlev!  
I had it in my collection allready, but it does not seem to work for me.  
Tell me if I used it correctly: [#1]

```
T=5
F=COMPOSERSORT
1=$cutRight($regexp(%COMPOSER%', ','(.*?)\\\\s(\\\\w*),\\\\s','$2, $1; '),2)If I use it, I on: FN1 LN1; FN2 LN2; FN3 LN3 

```

I get: LN3, FN1 LN1; FN2 LN2; FN3

Using Pone solution from the same thread, I get the same result.  
I don't know if I implemented it correctly, but it is not the result I hoped for.

I thing I found almost all the offered solutions from the forum, but either it is my missusing them or they don't work for me.

---

<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: [December 4, 2015, 9:06am UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/4 "2015-12-04T09:06:43Z")

</div>

> [@tagmusing](#):
>
> ... I had it in my collection allready, but it does not seem to work for me. ... I don't know if I implemented it correctly ...

The example formatstring accepts the comma as the input separator and writes the semicolon as the output separator:

**$cutRight($regexp(%COMPOSER%', ','(.\*?)\s(\w\*),\s','$2, $1; '),2)**

Example:

**"Johann Sebastian Bach, Wolfgang Amadeus Mozart, Ferruccio Busoni" -\>**

**"Bach, Johann Sebastian; Mozart, Wolfgang Amadeus; Busoni, Ferruccio"**

 

You have to adapt the example formatstring to your case, which uses the semicolon as the input separator:

 **$cutRight($regexp(%COMPOSER%'; ','(.\*?)\s(\w\*);\s','$2, $1; '),2)** 

Example:

 **"Johann Sebastian Bach; Wolfgang Amadeus Mozart; Ferruccio Busoni" -\>**

**"Bach, Johann Sebastian; Mozart, Wolfgang Amadeus; Busoni, Ferruccio"**

 

DD.20151204.1115.CET

---

<div class="post-metadata">

### Author: ![tagmusing](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/ee59a6/32.png) [@tagmusing](https://community.mp3tag.de/u/tagmusing)
#### Post date: [December 4, 2015, 5:24pm UTC](https://community.mp3tag.de/t/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/5 "2015-12-04T17:24:31Z")

</div>

That's it. Now it works.  
Once again thank you for your help!

---

<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/changing-firstnam-lastname-to-lastname-fisrtname-problem/17423/6 "2026-02-09T12:25:59Z")

</div>


