# Brackets display order - \[ \] ( ) { }

**URL:** https://community.mp3tag.de/t/brackets-display-order/18381
**Category:** Support
**Created:** [October 29, 2016, 6:31pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381 "2016-10-29T18:31:43Z")
**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: [October 29, 2016, 6:31pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/1 "2016-10-29T18:31:43Z")

</div>

Is there a way to achieve such order, at least in the \_FILENAME and / or TITLE tag field?:  
**Song  
Song [Some Info]  
Song (Some Info)  
Song {Some Info}**

Right now, if i use the  
**%\_filename%**  
for the sort order, I get  
**Song  
Song (Some Info)  
Song [Some Info]  
Song {Some Info}**

And what is interesting, in FreeCommander and Windows Explorer if I sort by "Name" I get order like this:  
**Song (Some Info)  
Song [Some Info]  
Song {Some Info}  
Song**

So my second question would be, how do I achieve order like that [by that "Name"] in Mp3tag? Or more preferably, the other way around: how do I achieve [in file manager in Windows 7 x64] the same order as in Mp3tag?

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [October 29, 2016, 6:48pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/2 "2016-10-29T18:48:58Z")

</div>

Use in **sort by** to achieve same order as your first option:

```
$replace($replace($replace(%title%,'[',1),'(',2),'{',3)

```

Use in **sort by** to achieve same order as FreeCommander and Win E:

```
$replace($replace($replace(%title%,'[',2),'(',3),'{',1)

```

What's happening here is self explanatory (I hope).

As long as you don't enter these in the **Value** or **Field** you'll be fine 🙂

---

<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: [October 29, 2016, 8:04pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/3 "2016-10-29T20:04:12Z")

</div>

> [@stevehero](#):
>
> Use in **sort by** to achieve same order as your first option:
> 
> ```
> $replace($replace($replace(%title%,'[',1),'(',2),'{',3)
> 
> ```
> 
> [...]  
> As long as you don't enter these in the **Value** or **Field** you'll be fine 🙂

Yes, that checks out, thank you very much. [Although I do not understand, why is there a single \>\>)\<\< at the end of the code and not four of them, to close the equation]

I've created a complete set of variations of filenames for testing, and with

```
Value: %_filename%
Field: %_filename%
Sort by: $replace($replace($replace(%_filename%,'[',1),'(',2),'{',3)I can sort them by FILENAME with my order applied to brackets:

```

[ ---\> ( ---\> {

But how do I get to export list of such files with that order retained? If I use

```
$filename(txt,utf-16)
$loop(%_path%)
%TITLE%$loopend()then my test set is spitted out as

```

**Song (Info) [Info]  
Song (Info) {Info} [Info]  
Song (Info) {Info}  
Song (Info) Part 2 [Info]  
Song (Info) Part 2 {Info} [Info]  
Song (Info) Part 2 {Info}  
Song (Info) Part 2  
Song (Info)  
Song [Info]  
Song {Info} [Info]  
Song {Info}  
Song Part 2 (Info)  
Song Part 2 [Info]  
Song Part 2 {Info}  
Song Part 2  
Song**

The order is retained, but my first is my last ["Song" is at the bottom of the list and at the top is the "Song (Info) [Info]" which should be the last]. I can reverse the sort results in main window by clicking the column header, by it does not effect what comes out in exported list

---

<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 29, 2016, 8:32pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/4 "2016-10-29T20:32:00Z")

</div>

QUOTE (zerow @ Oct 30 2016, 00:04) \<{POST\_SNAPBACK}\>

... If I use

```
$filename(txt,utf-16)
$loop(%_path%)
%TITLE%$loopend()then my test set is spitted out as

```

...I can reverse the sort results in main window by clicking the column header, by it does not effect what comes out in exported list

  
Yes, that is exactly what it says in the help:  
[https://docs.mp3tag.de/export](https://docs.mp3tag.de/export)  
"$loop(%fieldname%) starts a new loop. The loop data is sorted by the fieldname."

The export is independent from the order of files in the files list. Only the selected files are relevant for the export.  
You would have to apply the same sorting criterion in the export as you have in the files list to get the same result (and select all the files).

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [October 29, 2016, 8:47pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/5 "2016-10-29T20:47:01Z")

</div>

> [@zerow](#):
>
> Yes, that checks out, thank you very much. [Although I do not understand, why is there a single \>\>)\<\< at the end of the code and not four of them, to close the equation]

Quite simple really.

If you have 1 opening ( there needs to be the same on the other side. So 3 x ( and 3 x ) on the right.

The syntax for one replace fn is:

```
$replace(string,from,to)

```

So two replace functions is:

```
$replace($replace(string,from,to),from,to)

```

Three is:

```
$replace($replace($replace(string,from,to),from,to),from,to)

```

.. and so on. The fn just so happens to lie outside.

I also write 3ds Max scripts with maxscript and it's syntax for functions is:

```
fn dosomethingcool = (
   place some cool code here
)

```

And then:

```
dosomethingcool()

```

which will run that function.

Each coding syntax is different. Much like English vs. Dutch 🙂

* * *

> [@zerow](#):
>
> The order is retained, but my first is my last ["Song" is at the bottom of the list and at the top is the "Song (Info) [Info]" which should be the last]. I can reverse the sort results in main window by clicking the column header, by it does not effect what comes out in exported list

Try this on your files:

```
$filename(C:\Test Export on $regexp(%_date%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-8)
TEST EXPORT on $regexp(%_date%,'(\d\d)/(\d\d)/\d\d(\d\d)','$1-$2-$3')
-------------------------------------
$loop($replace($replace($replace(%path%,'[',1),'(',2),'{',3))
%title%$loopend()

```

I've tried it with:

```
Song
Song [Info]
Song (Info) [Info]
Song (Info) {Info}
Song (Info) Part 2 {Info} [Info]
Song {Info}
Song Part 2
Song Part 2 {Info}

```

And it's output is the same as the fields:

```
TEST EXPORT on 29-10-16
-------------------------------------

Song
Song [Info]
Song (Info) [Info]
Song (Info) {Info}
Song (Info) Part 2 {Info} [Info]
Song {Info}
Song Part 2
Song Part 2 {Info}

```

---

<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: [October 30, 2016, 4:02pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/6 "2016-10-30T16:02:40Z")

</div>

> [@stevehero](#):
>
> Quite simple really.  
> [..]  
> So two replace functions is:
> 
> ```
> $replace($replace(string,from,to),from,to)
> 
> ```

Yes, now I see it clearly

I had too many hours of work yesterday

QUOTE (stevehero @ Oct 30 2016, 00:47) \<{POST\_SNAPBACK}\>

Try this on your files:

```
$filename(C:\Test Export on $regexp(%_date%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-8)
TEST EXPORT on $regexp(%_date%,'(\d\d)/(\d\d)/\d\d(\d\d)','$1-$2-$3')
-------------------------------------
$loop($replace($replace($replace(%path%,'[',1),'(',2),'{',3))
%title%$loopend()<!--QuoteEnd--></div><!--QuoteEEnd-->Thank you very much

```

I've modified it a little, to this

```
$filename(C:\Windows\Temp\Mp3tag TITLE $regexp(%_DATE%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-16)$loop($replace($replace($replace($replace(%PATH%,'[',1),'(',2),'{',3),'+',4))%TITLE%
$loopend()

```

And so, know I have such order in a expanded sample set:

**A  
A + A  
Song  
Song [Info]  
Song [Info] + Song [Info]  
Song (Info)  
Song (Info) [Info]  
Song (Info) [Info] + Song (Info) [Info]  
Song (Info) {Info}  
Song (Info) {Info} [Info]  
Song (Info) {Info} [Info] + Song (Info) {Info} [Info]  
Song (Info) {Info} + Song (Info) {Info}  
Song (Info) + Song (Info)  
Song (Info) Part 2  
Song (Info) Part 2 [Info]  
Song (Info) Part 2 [Info] + Song (Info) Part 2 [Info]  
Song (Info) Part 2 {Info}  
Song (Info) Part 2 {Info} [Info]  
Song (Info) Part 2 {Info} [Info] + Song (Info) Part 2 {Info} [Info]  
Song (Info) Part 2 {Info} + Song (Info) Part 2 {Info}  
Song (Info) Part 2 + Song (Info) Part 2  
Song {Info}  
Song {Info} [Info]  
Song {Info} [Info] + Song {Info} [Info]  
Song {Info} + Song {Info}  
Song + Song  
Song Part 2  
Song Part 2 [Info]  
Song Part 2 [Info] + Song Part 2 [Info]  
Song Part 2 (Info)  
Song Part 2 (Info) + Song Part 2 (Info)  
Song Part 2 {Info}  
Song Part 2 {Info} + Song Part 2 {Info}  
Song Part 2 + Song Part 2  
Z  
Z + Z**  
   
The \>\>+\<\< means that there are two tracks in one file, with smooth transition in between. So there are four steps to account for

So should I modified it also to

```
'$4-$3-$2-$1'
'$1-$2-$3-$4'?

```

---

<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: [October 30, 2016, 5:31pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/7 "2016-10-30T17:31:35Z")

</div>

QUOTE (zerow @ Oct 30 2016, 18:02) \<{POST\_SNAPBACK}\>

[...]

I've modified it a little, to this

```
$filename(C:\Windows\Temp\Mp3tag TITLE $regexp(%_DATE%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-16)$loop($replace($replace($replace($replace(%PATH%,'[',1),'(',2),'{',3),'+',4))%TITLE%
$loopend()[...]<!--QuoteEnd--></div><!--QuoteEEnd-->And there is also this one small issue with this code

```

If I select this export action in export Window [CTRL + E], then the  
**"Export file name:"**  
changes automatically to

```
C:\Windows\Temp\Mp3tag TITLE $regexp(%_DATE%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txtremoving the path defined by me

```

And so, if I select a simple export action like

```
$filename(txt,utf-16)
$loop(%ALBUM%,1)
%ALBUM%
$loopend()then it still shows the
C:\Windows\Temp\Mp3tag TITLE $regexp(%_DATE%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txtpath

```

How can I force Mp3tag to remember the default file for exports, that do not specify a file name / path. Or should I specify a file in every export action?

---

<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 30, 2016, 6:14pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/8 "2016-10-30T18:14:17Z")

</div>

> [@zerow](#):
>
> ...  
> How can I force Mp3tag to remember the default file for exports, that do not specify a file name / path. Or should I specify a file in every export action?

See File\>Options\>Export

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [October 30, 2016, 7:48pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/9 "2016-10-30T19:48:15Z")

</div>

All this seems to be terribly over complicated.

Have to tried opening the text file in notepad++ and using a plugin for that called TextFX. It has a function under TextFX menu (once you install it) \> TextFX Tools \> Sort line (case senitive).

I'm not sure what you mean by:

```
'$4-$3-$2-$1'
'$1-$2-$3-$4'
```

---

<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: [October 31, 2016, 11:22am UTC](https://community.mp3tag.de/t/brackets-display-order/18381/10 "2016-10-31T11:22:19Z")

</div>

> [@zerow](#):
>
> [...]  
> How can I force Mp3tag to remember the default file for exports, that do not specify a file name / path. Or should I specify a file in every export action?

> [@ohrenkino](#):
>
> See File\>Options\>Export

Just as a I suspected- it does not hold  
I stays only until I select later on an export action which specifies its own file- and it gets carried over onto other exports. And also in  
**See File \> Options \> Export \> Export file name**   
the location / name of file is changed

---

<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: [October 31, 2016, 11:34am UTC](https://community.mp3tag.de/t/brackets-display-order/18381/11 "2016-10-31T11:34:51Z")

</div>

> [@stevehero](#):
>
> All this seems to be terribly over complicated.
> 
> Have to tried opening the text file in notepad++ and using a plugin for that called TextFX. It has a function under TextFX menu (once you install it) \> TextFX Tools \> Sort line (case senitive).

As a mather of fact I have some very complicated export action that I finish with with that option in Notepad++, because there is no other way

But that new one here pretty much works [or will be working] within Mp3tag, so there is no need for additional clicking in Notepad++

QUOTE (stevehero @ Oct 30 2016, 21:48) \<{POST\_SNAPBACK}\>

I'm not sure what you mean by:

```
'$4-$3-$2-$1'
'$1-$2-$3-$4'<!--QuoteEnd--></div><!--QuoteEEnd-->

```

QUOTE (stevehero @ Oct 29 2016, 23:47) \<{POST\_SNAPBACK}\>

 $filename(C:\Test Export on $regexp(%\_date%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-8)

```
TEST EXPORT on $regexp(%_date%,'(\d\d)/(\d\d)/\d\d(\d\d)','$1-$2-$3')
-------------------------------------
$loop($replace($replace($replace(%path%,'[',1),'(',2),'{',3))
%title%$loopend()<!--QuoteEnd--></div><!--QuoteEEnd-->

```

Is this

```
$3
$2
$1

```

in relation to the

```
(\d\d)
(\d\d)
(\d\d\d\d)or is it in relation to
[,1)
(',2)
{',3)?

```

---

<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 31, 2016, 3:44pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/12 "2016-10-31T15:44:22Z")

</div>

> [@zerow](#):
>
> Just as a I suspected- it does not hold  
> I stays only until I select later on an export action which specifies its own file- and it gets carried over onto other exports. And also in  
> **See File \> Options \> Export \> Export file name**   
> the location / name of file is changed

Yes: that what you enter in File\>Options\>Export sets the variable $filename in a report - unless you have defined a filename in the export.  
You will notice that the set filename adopts the extension of the $filename() statement in the export.  
So you either centrally define a format string for the $filename() statement in the Export dialogue or you specify an special one in an export which is then taken as standard for all those exports that do not define their own filename.

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [October 31, 2016, 4:52pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/13 "2016-10-31T16:52:15Z")

</div>

QUOTE (zerow @ Oct 31 2016, 12:34) \<{POST\_SNAPBACK}\>

Is this

```
$3
$2
$1

```

in relation to the

```
(\d\d)
(\d\d)
(\d\d\d\d)or is it in relation to
[,1)
(',2)
{',3)?<!--QuoteEnd--></div><!--QuoteEEnd-->

```

This just formats the current date to DD-MM-YY as opposed to DD-MM-YYYY  
**$regexp(%\_date%,'(\d\d)/(\d\d)/\d\d(\d\d)','$1-$2-$3')**

**The first (\d\d) matches & captures the date as $1. \d in regexp = a numerical value from 0-9**

/ matches a /(\d\d) matches and captures the month as $2/ matches a /\d\d matches two numerical value from 0-9. This can aslo be wrote as \d{2}(\d\d) matches and captures the year as $3. In this case 16

```
$regexp(%_date%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1')

```

Is just a variation on that. Notice the $3, $2, $1 order and the () used as capturing devices are changed position resulting in YYYY-MM-DD whereas the initial date was formatted DD-MM-YYYY.

* * *

You'll learn more by watching this ( **skip the first 2 mins** ):  
[https://www.youtube.com/watch?v=DRR9fOXkfRE](https://www.youtube.com/watch?v=DRR9fOXkfRE)

Loads of websites allow you to test and learn regexp like:  
[https://regex101.com/](https://regex101.com/)

---

<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: [October 31, 2016, 9:15pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/14 "2016-10-31T21:15:52Z")

</div>

> [@stevehero](#):
>
> This just formats the current date to DD-MM-YY as opposed to DD-MM-YYYY  
> [...]

> [@ohrenkino](#):
>
> ]...]  
> You will notice that the set filename adopts the extension of the $filename() statement in the export.  
> [...]

Now I get it; now I have those exported files the way I want them to be

I've just put

```
$filename(C:\Users\***\Documents\! Mp3tag export list.txt,utf-16)in every one that did not had already specification for a path / name

```

> [@zerow](#):
>
> [...]  
> But that new one here pretty much works [or will be working] within Mp3tag, so there is no need for additional clicking in Notepad++

Almost

When used for sorting in columns, the stevehero code

```
$replace($replace($replace(%title%,'[',1),'(',2),'{',3)gives order like this

```

**Song A  
Song A + Song B  
Song A   
Song A ()  
Song A {}  
Song A Part 2**  
 which is almost correct [because the plus sign, indicating in my book a second song, should be shown after the variations of only the first song are listed]. So as I mentioned, I modified the code to

```
$replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)which gave me the order which I was after

```

**Song A  
Song A   
Song A ()  
Song A {}  
Song A + Song B  
Song A Part 2**  
[Yes, the "Song A Part 2" could be also considered as variations of "Song A", but not in my book; that is not important here]

But if I go further with modification to the form of

```
$replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)(%ARTIST%)the code goes bunkers. That additional ARTIST parameter do gives me what I need, which is order of also artists. So now the code will make a list

```

**Song A ### by performer ### Band X  
Song A ### by performer ### Band Y  
Song A ### by performer ### Band Z  
Song B ### by performer ### Band X  
Song B ### by performer ### Band Y  
Song B ### by performer ### Band Z**  
But unfortunately it will also at the same time turn the working order which I was after into faulty order  
**Song A   
Song A ()  
Song A {}  
Song A + Song B  
Song A Part 2  
Song A**

> [@stevehero](#):
>
> All this seems to be terribly over complicated  
> [...]

So the last two lists above are produced by the same code, but I separated the two orders [of FILENAME and ARTIST] to show more clearly, what is happening. But in broader spectrum what I need is this  
**Song A ### by performer ### Band X  
Song A ### by performer ### Band X  
Song A () ### by performer ### Band X  
Song A () ### by performer ### Band Y  
Song A () ### by performer ### Band Z  
Song A {} ### by performer ### Band X  
Song A + Song B ### by performer ### Band X  
Song A Part 2 ### by performer ### Band X**  
but somehow I get ending up with this  
**Song A ### by performer ### Band X  
Song A () ### by performer ### Band X  
Song A () ### by performer ### Band Y  
Song A () ### by performer ### Band Z  
Song A {} ### by performer ### Band X  
Song A + Song B ### by performer ### Band X  
Song A Part 2 ### by performer ### Band X  
Song A ### by performer ### Band X**  
with the code

```
$replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)(%ARTIST%)

```

Simply: what should be on the top [and is when using  
$replace($replace($replace($replace(%\_FILENAME%,'[',1),'(',2),'{',3),'+',4)now gets dropped to the bottom because of that addition of ARTIST

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [October 31, 2016, 10:40pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/15 "2016-10-31T22:40:32Z")

</div>

> [@zerow](#):
>
> Simply: what should be on the top [and is when using
> 
> ```
> $replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)now gets dropped to the bottom because of that addition of ARTIST
> 
> ```

Try using in **Sort By** part of column settings:

```
$replace($replace($replace($replace(%_filename%,'[',1),'(',2),'{',3),'+',4) $replace($replace($replace($replace(%artist%,'[',1),'(',2),'{',3),'+',4)

```

And in **export** :

```
$filename(C:\Users\yourusername\Desktop\Test Export on $regexp(%_date%,'(\d\d)/(\d\d)/(\d\d\d\d)','$3-$2-$1').txt,utf-8)
TEST EXPORT on $regexp(%_date%,'(\d\d)/(\d\d)/\d\d(\d\d)','$1-$2-$3')
-------------------------------------
$loop($replace($replace($replace($replace(%_filename%,'[',1),'(',2),'{',3),'+',4) $replace($replace($replace($replace(%artist%,'[',1),'(',2),'{',3),'+',4))
%title%$loopend()

```

Not tested with your samples so try that out for size 🙂

---

<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: [November 1, 2016, 11:24am UTC](https://community.mp3tag.de/t/brackets-display-order/18381/16 "2016-11-01T11:24:53Z")

</div>

> [@zerow](#):
>
> [...]  
> Simply: what should be on the top [and is when using
> 
> ```
> $replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)now gets dropped to the bottom because of that addition of ARTIST
> 
> ```

> [@stevehero](#):
>
> Try using in **Sort By** part of column settings:
> 
> ```
> $replace($replace($replace($replace(%_filename%,'[',1),'(',2),'{',3),'+',4) $replace($replace($replace($replace(%artist%,'[',1),'(',2),'{',3),'+',4)
> 
> ```

It is still the same; ordinary / simple titles get dropped to the bottom

I think this would be overcome, if there were five "rules" instead of four: the first one [telling what should be at the top] should specify every other character than  
**[  
(  
{  
+**  
 So some kind of booleean function would firstly have to list [out] those four signs?

> [@stevehero](#):
>
> And in **export** :  
> [...]

Once I have a working code for sorting, I should be able from that point to adapt it on my own for export action

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 1, 2016, 11:44am UTC](https://community.mp3tag.de/t/brackets-display-order/18381/17 "2016-11-01T11:44:01Z")

</div>

> [@zerow](#):
>
> It is still the same; ordinary / simple titles get dropped to the bottom
> 
> I think this would be overcome, if there were five "rules" instead of four: the first one [telling what should be at the top] should specify every other character than  
> **[  
> (  
> {  
> +**  
> So some kind of booleean function would firstly have to list [out] those four signs?
> 
> Once I have a working code for sorting, I should be able from that point to adapt it on my own for export action

Try:

```
$replace($replace($replace($replace($regexp(%_filename%,'[^\[\(\{+]',1)'[',2),'(',3),'{',4),'+',5) $replace($replace($replace($replace($regexp(%artist%,'[^\[\(\{+]',1),'[',2),'(',3),'{',4),'+',5)

```

This replaces file names that DON'T have **[ ( { +** with **1** and the rest are renumbered from 2-5.

[^[({+] in regular expression terms means anything that is not any of the characters **[ ( { +**

Tested and returns:

```
Song A ### by performer ### Band X
Song A [] ### by performer ### Band X
Song A () ### by performer ### Band X
Song A () ### by performer ### Band Y
Song A () ### by performer ### Band Z
Song A {} ### by performer ### Band X
Song A + Song B ### by performer ### Band X
Song A Part 2 ### by performer ### Band X

```

---

<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: [November 1, 2016, 4:53pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/18 "2016-11-01T16:53:06Z")

</div>

> [@stevehero](#):
>
> Try:
> 
> ```
> $replace($replace($replace($replace($regexp(%_filename%,'[^\[\(\{+]',1)'[',2),'(',3),'{',4),'+',5) $replace($replace($replace($replace($regexp(%artist%,'[^\[\(\{+]',1),'[',2),'(',3),'{',4),'+',5)
> 
> ```

Shouldn't there be also the \>\>\<\< between \>\>{\<\< and \>\>+\<\<?

I've tried both

```
$replace($replace($replace($replace($regexp(%_filename%,'[^\[\(\{+]',1)'[',2),'(',3),'{',4),'+',5)$replace($replace($replace($replace($regexp(%artist%,'[^\[\(\{+]',1),'[',2),'(',3),'{',4),'+',5)

$replace($replace($replace($replace($regexp(%_filename%,'[^\[\(\{\+]',1)'[',2),'(',3),'{',4),'+',5)$replace($replace($replace($replace($regexp(%artist%,'[^\[\(\{+]',1),'[',2),'(',3),'{',4),'+',5)With them if all tracks are by the same ARTIST, then the columns does not respond- I click and nothing changes. So I can't reverse the order, which isn't even correct, because it still drops to the bottom what should be at the top

```

And if the tracks have different value in the ARTIST field, then the column does respond by reversing order. But I only have order of artist, because filenames are grouped [by ARTIST] and also still drop to the bottom what should be at the top

QUOTE (stevehero @ Nov 1 2016, 13:44) \<{POST\_SNAPBACK}\>

Tested and returns:

```
Song A ### by performer ### Band X
Song A [] ### by performer ### Band X
Song A () ### by performer ### Band X
Song A () ### by performer ### Band Y
Song A () ### by performer ### Band Z
Song A {} ### by performer ### Band X
Song A + Song B ### by performer ### Band X
Song A Part 2 ### by performer ### Band X<!--QuoteEnd--></div><!--QuoteEEnd-->Are you sure?

```

---

<div class="post-metadata">

### Author: ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)
#### Post date: [November 2, 2016, 9:32pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/19 "2016-11-02T21:32:01Z")

</div>

> [@zerow](#):
>
> Shouldn't there be also the \>\>\<\< between \>\>{\<\< and \>\>+\<\<?

Not when you precide and close with [and]. They are special functions for regexp.

[adf] = match any of the chars adf  
[^adf] = matches any chars that are not adf.

Much like [a-s] will match any chars from a-s.  
This is often wrote [a-z] but you can limit it like above.

I could of wrote that like so:

> [@](#):
>
> [\[1\]

Instead of:

```
[^\[\(\{+]

```

which funnily enough does the same thing. Why? you ask, because to match **\</b\> as a literal you have to put \\**

 

so **(** will always match **(**

I could write here all day about regular expressions but it's best if you watch youtube videos and practice yourself.

Also writing regular expressions is bespoke for every user so it's worth a day or so to watch them videos and learn. It's an amazing thing to learn. I can rename 1,000's of files on my computer using freecommanders rename tool which uses regexp. Very handy.

> [@zerow](#):
>
> I've tried both...

Try:

```
$replace($replace($replace($replace($regexp(%_filename%,'^(.?[^[({+]+?$)',1$1),'[',2),'(',3),'{',4),'+',5) $replace($replace($replace($replace($regexp(%artist%,'^(.?[^[({+]+?$)',1$1),'[',2),'(',3),'{',4),'+',5)

```

Look at the attached to study what each part does of this regexp.

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

* * *

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: [November 7, 2016, 8:39pm UTC](https://community.mp3tag.de/t/brackets-display-order/18381/20 "2016-11-07T20:39:12Z")

</div>

> [@stevehero](#):
>
> [...]  
> Try:
> 
> ```
> $replace($replace($replace($replace($regexp(%_filename%,'^(.?[^[({+]+?$)',1$1),'[',2),'(',3),'{',4),'+',5) $replace($replace($replace($replace($regexp(%artist%,'^(.?[^[({+]+?$)',1$1),'[',2),'(',3),'{',4),'+',5)
> 
> ```

Well, artists are now in order

But overall I got FILENAME order like this

```
A
Song Part 2
Song
Z
A + A
Song VARIATIONS WITH BRACKETS IN THE IN-CORRECT ORDER
Song + Song
Z + Z

```

While it should be

```
A
A + A
Song
Song VARIATIONS WITH BRACKETS IN THE CORRECT ORDER
Song + Song
Song Part 2
Z
Z + Z

```

Making the "A" and "Z" in order would probably also straighten out the order of brackets

But for now I just firstly sort by ARTIST and then use this simpler code

```
$replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4)which gives me both order of files with my rules, but also listing them in order of artists

```

[So I just spent two hours on trying to make this work, while I could just be clicking two columns instead of one. And I haven't even approach the issue of "^" which I use as another special indicator when the brackets are not enough, which probably make me headache even worse]

As for the export I do not have to add sorting criterion

> [@ohrenkino](#):
>
> [...]  
> The export is independent from the order of files in the files list. Only the selected files are relevant for the export.  
> You would have to apply the same sorting criterion in the export as you have in the files list to get the same result (and select all the files).

Because in case of exporting I can also just sort the files by ARTIST and the select them all and apply this code to them

```
$filename(C:\Users\***\Documents\! Mp3tag export list.txt,utf-16)
$loop($replace($replace($replace($replace(%_FILENAME%,'[',1),'(',2),'{',3),'+',4))
%_FILENAME%
$loopend()to get the same results as in main window

```

> [@stevehero](#):
>
> Look at the attached to study what each part does of this regexp.

Is this some kind of editor, that like HTML editors applies colors, so that the user can see, if there is something missing?

[Next page](https://community.mp3tag.de/t/brackets-display-order/18381.md?page=2)
