# An action to re-order text?

**URL:** <https://community.mp3tag.de/t/an-action-to-re-order-text/16152>\
**Category:** Support\
**Created:** [September 17, 2014, 8:14pm UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152 "2014-09-17T20:14:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigrun](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@sigrun](https://community.mp3tag.de/u/sigrun)\
**Post date:** [September 17, 2014, 8:14pm UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152/1 "2014-09-17T20:14:36Z")

</div>

I am trying to format my classical music. So in the title field I want to move the Op. number to the beginning.

So for example the track title might be:

Piano Sonata No. 2 in B-flat minor Op. 35 "Funeral March" - 2. Scherzo

I want it to be:

Op. 35 - Piano Sonata No. 2 in B-flat minor "Funeral March" - 2. Scherzo

Of course the Op. number isn't always going to be the same.

I tried to create an action myself for this, but it's too difficult.

Any help would be appreciated, 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:** [September 18, 2014, 3:57am UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152/2 "2014-09-18T03:57:00Z")

</div>

> [@sigrun](#):
>
> ... example the track title might be:
> 
> Piano Sonata No. 2 in B-flat minor Op. 35 "Funeral March" - 2. Scherzo
> 
> I want it to be:
> 
> Op. 35 - Piano Sonata No. 2 in B-flat minor "Funeral March" - 2. Scherzo  
> ..

If the "Op." is the separator and always followed by a number, you can try an action of the type  
"Replace with regular expression" for TITLE  
Search: (._) Op. (\d+) (._)  
Replace: Op. $2 $1 $3

---

<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:** [September 18, 2014, 5:19am UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152/3 "2014-09-18T05:19:04Z")

</div>

> [@sigrun](#):
>
> ... in the title field I want to move the Op. number to the beginning. ...  
> Piano Sonata No. 2 in B-flat minor Op. 35 "Funeral March" - 2. Scherzo  
> I want it to be:  
> Op. 35 - Piano Sonata No. 2 in B-flat minor "Funeral March" - 2. Scherzo  
> Of course the Op. number isn't always going to be the same. ...

Action: Format value  
Field: TITLE  
Formatstring: **$regexp(%TITLE%,'^(.+?)\b(?:op.?|opus)\s?(\d+),?\s?(.+?)$','Op. $2 - $1$3',1)**

**From: aaa op123 bbb aaa op 123 bbb aaa op.123 bbb aaa op. 123 bbb aaa opus123 bbb aaa opus 123 bbb To: Op. 123 - aaa bbb**

DD.20140918.0919.CEST

---

<div class="post-metadata">

**Author:** ![sigrun](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/eb9ed0/32.png) [@sigrun](https://community.mp3tag.de/u/sigrun)\
**Post date:** [September 18, 2014, 6:27pm UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152/4 "2014-09-18T18:27:10Z")

</div>

> [@DetlevD](#):
>
> Action: Format value  
> Field: TITLE  
> Formatstring: **$regexp(%TITLE%,'^(.+?)\b(?😲p.?|opus)\s?(\d+),?\s?(.+?)$','Op. $2 - $1$3',1)**
> 
> **From: aaa op123 bbb aaa op 123 bbb aaa op.123 bbb aaa op. 123 bbb aaa opus123 bbb aaa opus 123 bbb To: Op. 123 - aaa bbb**
> 
> DD.20140918.0919.CEST

Brilliant! Thanks!

I have noticed one flaw: if the Op. number is at the end of the title it will only take the first digit.

So "Op. 23" is moved as "Op. 2" and "3" stays at the end.

I added an action to the group that adds text to the title before running your action & then removes it after running, which solves it.

---

<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:** [September 19, 2014, 4:30am UTC](https://community.mp3tag.de/t/an-action-to-re-order-text/16152/5 "2014-09-19T04:30:51Z")

</div>

> [@sigrun](#):
>
> Brilliant! Thanks! I have noticed one flaw: if the Op. number is at the end of the title it will only take the first digit. So "Op. 23" is moved as "Op. 2" and "3" stays at the end. ...

That's another starting point, but you can build quickly the new regular expression, which works also without the last part " bbb".

Action: Format value  
Field: TITLE  
Formatstring: **$regexp(%TITLE%,'^(.+?)?\s?(?:op.?|opus)\s?(\d+),?\s?(.+?)?$','Op. $2 - $1$3',1)**

DD.20140919.0940.CEST

---

<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/an-action-to-re-order-text/16152/6 "2026-02-09T12:25:16Z")

</div>

Closed on February 9, 2026, 12:25pm UTC


