Brackets display order - [ ] ( ) { }

Unfortunately I cannot expand this simply to

$replace($replace($replace($replace($replace($replace(
%_FILENAME%,'[',1),'^',2),'#',3),'(',4),'{',5),'+',6)to achieve a complete order

Song
Song ^0
Song #0
Song [
Song (
Song {
Song +

[where >>0<< means any number, because I always put a number after both >>^<< and >>#<< signs]

because I get faulty order

Song
Song [
Song (
Song {
Song +
Song #0
Song ^0

I've tried adding >>\d<< to both or one of them

$replace($replace($replace($replace($replace($replace(
%_FILENAME%,'[',1),'^\d',2),'#\d',3),'(',4),'{',5),'+',6)

$replace($replace($replace($replace($replace($replace(
%_FILENAME%,'[',1),'^\d',2),'#',3),'(',4),'{',5),'+',6)

$replace($replace($replace($replace($replace($replace(
%_FILENAME%,'[',1),'^',2),'#\d',3),'(',4),'{',5),'+',6)as I follow them in my book with numbers anyhow, but surprise, surprise: I ran into other incorret order

Apparently those two signs [^ and #] are treated differently than three kinds of brackets signs. Why? And more important: how to put them in the code as "normal" signs?

Instead of my giving you the answer. :wink:

To use \d you need to use the function regexp and not replace.

Your syntax is wrong.

As that did nothing

$replace($regexp($regexp($replace($replace($replace(
%_FILENAME%,'[',1),'^\d',2),'#\d',3),'(',4),'{',5),'+',6)

I guesses it should be more something like

$replace($replace($replace($replace($replace($replace(
%_FILENAME%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'(',4),'{',5),'+',6)

Only with that something being something else than this something, and which was something I was not able to work out. [Yes, I am much better of a comedian than a coder]

Right, please study what I've shown you such as the videos and links.

^ in regular expressions needs to be escaped by using ^ to find it as a literal

^ on it's own simply means match beginning of string.

I've given a website in this thread and also a simple google will come up with lots more websites to try/learn it. The above would be in the first page of any regular expression page explaining literals. Like: http://www.regular-expressions.info/characters.html

http://www.regular-expressions.info/tutorial.html is a good link to learn. It's where I did. Back then YouTube didn't but you've a lot of places to learn it now.

If you try this URL you'll also find what you're looking for to test your regexp http://bfy.tw/8frA

Regarding your crazy syntax:

$replace($replace($replace($replace($replace($replace(%_FILENAME%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'(',4),'{',5),'+',6)

I showed you the correct syntax here:
Brackets display order - [ ] ( ) { }


To end this thread for me:

Google 'regular expression ^ as literal' and I bet it'll come back with ^ or an explanation for it, that it's a special character used in regular expressions.

This is the working one I've came up with based on your 5 different examples, colour coded and all.
$replace($replace($replace($replace($regexp($regexp($regexp(%title%,'^(.?[^^#[({+]+?$)',1$1),'^\d',2),'#\d',3),'[',4),'(',5),'{',6),'+',7)

NOTICE the position of the $regexp in relation to the regular expressions on the right.
It works from the %title% to the left and to the right and from the red text inwards. Look at the part of the thread here showing correct syntax.

Anyway the above code does this sorting: I'm not sure of this is right because every example you come up with is different.

So, for your export:

$filename(C:\Users\username\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($regexp($regexp($regexp(%_filename%,'^(.?[^^#[({+]+?$)',1$1),'\^\d',2),'#\d',3),'[',4),'(',5),'{',6),'+',7) $replace($replace($replace($replace($regexp($regexp($regexp(%artist%,'^(.?[^^#[({+]+?$)',1$1),'\^\d',2),'#\d',3),'[',4),'(',5),'{',6),'+',7))
%title%$loopend()

Will now export:

Song
Song ^0
Song #0
Song [
Song (
Song {
Song +
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

[Going back to "basics"...]


So I made some changes to the order of titles of songs that I seek .This is what I need:

  • Song
  • Song B
  • Song B [Something]
  • Song B {Something}
  • Song B {Something} [Something]
  • Song B (Something) [Something]
  • Song B (Something) {Something}
  • Song B (Something) {Something} [Something]
  • Song B + Song C
  • Song C

So the order of brackets is this: [ { (. And the brackets follow titles without brackets. And if there is as >> + << or something else then it should just be treated as a non-bracket, and non-brackets follow brackets

And as the default sort order is:

  • Song
  • Song B
  • Song B (Something) [Something]
  • Song B (Something) {Something}
  • Song B (Something) {Something} [Something]
  • Song B [Something]
  • Song B {Something}
  • Song B {Something} [Something]
  • Song B + Song C
  • Song C

so it would seem that I could just use
$replace($replace($replace($replace(%TITLE%,'[',1),'{',2),'(',3),'+',4))
or
$replace($replace($replace(%TITLE%,'[',1),'{',2),'(',3))
but no, the order gets totally messed up with such codes


It also would seem that as an alternative all I would have to do is to use something as simple as $replace(%TITLE% ,'(','')
just to throw the >>(<< down. And it does get to the bottom with this short code, but the >>Song B + Song C<< is above it:

  • Song
  • Song B
  • Song B [Something]
  • Song B {Something}
  • Song B {Something} [Something]
  • Song B + Song C
  • Song B (Something) [Something]
  • Song B (Something) {Something}
  • Song B (Something) {Something} [Something]
  • Song C

So then I would have also to throw the >>+<< down, right? Unfortunatelly, after extending the code to
$replace(%TITLE% ,'(','','+','(')
it gets bumped up above all brackets, instead going below them:

  • Song
  • Song B
  • Song B + Song C
  • Song B [Something]
  • Song B {Something}
  • Song B {Something} [Something]
  • Song B (Something) [Something]
  • Song B (Something) {Something}
  • Song B (Something) {Something} [Something]
  • Song C

So maybe reversing that last part will help- by sending it down instead up? No, the
$replace(%TITLE% ,'(','','(','+')
version reverts to the previous state:

  • Song
  • Song B
  • Song B [Something]
  • Song B {Something}
  • Song B {Something} [Something]
  • Song B + Song C
  • Song B (Something) [Something]
  • Song B (Something) {Something}
  • Song B (Something) {Something} [Something]
  • Song C

So maybe reverse whole parts of the code ? Well
$replace(%TITLE% ,'(','+', '(','')
also gives no change, as well as
$replace(%TITLE% ,'+','(', '(','')


Long story short- I was tempering with my code, adding parts to it [i.e. including >>[<< and >>{<<], inserting pauses between signs; and also going back and forth between what @stevehero has kindly provided me with and that work of mine- but I did never get my desired order [listed at the very top of this post]. I always had at at least one misplaced element


Can anyone ease my headache?

As far as I understood @stevehero he simply replaced every bracket with a number.
So you just have to set which symbol should appear at which position like
..[ = 1
..{ = 2
..+ = 3
..( = 4
so it could be
$replace(%title%,'[',1,'{',2,+,3,'(',4)

A personal note: whatever reasons may lead to the preference of this order - it is rather unlikely that any other implementation will follow it. So the adapation of the order will only have a local effect. And as we all try to avoid too many clicks, the whole effort of reordering is in vain. In my opinion. Others may have other good reasons.

I got to the point where sorting with a code like

$replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'+',4),'{',5),'(',6),'#',7)

works A-OK when it is put for a Column in its Sort by field. But if try to extend it by one more step

$replace($replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'^',4),'+',5),'{',6),'(',7),'#',8)

then it wrongly places >>^<< after >>(<<, instead after >>[<<. Is it because it that >>^<< sign is used in regular expressions?


The current correct order should be:

Song
Song [Anything]
Song [Anything] + Song C
Song + Song C
Song ^1
Song ^1 [Anything]
Song ^1 [Anything] + Song C
Song ^2
Song {Anything}
Song (Anything)
Song #1
Song #1 [Anything]
Song #1 [Anything] + Song C
Song #1 + Song C
Song #1 {Anything}
Song #1 (Anything)
Song #2-3
Song B
Song C

which can be also presented like this

[ + ^ { ( #

The ^ means "beginning of field" in the context of a regular expression.
You may have to escape it: \^

Such adjustment to

$replace($replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'+',4),'\^',5),'{',6),'(',7),'#',8)

does not work. The order is as slighty wrong as before

As you know that you can test the regular expressions as well as any other kind of scripting function in Convert>Tag-Tag, I would recommend to test each of the various sections whether they work as expected and then put it all together.

I eliminated the >>^<< as culprit by adding into the set of files test ones

Song @1
Song @1 [Anything]
Song @1 [Anything] + Song C

and using code

$replace($replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'+',4),'@',5),'{',6),'(',7),'#',8)

The result was the same, with the >> @ << being after >> ( <<, instead being after >> [ <<

I am beginning to suspect that the code works with 7 variables [the $replace being used 7 times] works A-OK only by happenstance- because it forces part of its supposed order rules onto the normal sort order rules. The result is a mix which happens to be what I need, but only by a pure chance that is. Because in 2016 I was using version with 6, then with 7- but when now I go 8, something breaks. Breaks either a code [is it possible?] or illusion of the code in shorter version being 100% correct [which is possible]

I do not understand what that feature has to do with a sort order in Columns. When I put via the Convert > Tag-Tag that "8th level" code

$replace($replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'+',4),'@',5),'{',6),'(',7),'#',8)

while having in selection Song @1 and I see Song 51 as a result to be. And when I when use code

$replace($replace($replace($replace($replace($replace($replace(%TITLE%,'[',1),'$regexp(something ^\d)',2),'$regexp(something #\d)',3),'+',4),'{',5),'(',6),'#',7)

on Song @1 I still see Song @1

This only tells me that my suspicion is correct- version for 7 works [by happenstance] because for 8 it spills out gibberish for the sign / part in question

Sorting works if you replace the actual character with one of your choice.
So testing your expression should proove for a particular file that the actual character really gets replaced as you intended.

I took me a while to wrap my head around what you meant but now I get it, how works that Convert > Tag-Tag feature:

When I saw Song @1 I saw that it was not reworked by the code [by the 7th level version which had no >>@<< in the code]. And when I saw Song 51 I saw how the code was working- it was changing it to the 5th place in the sort order

`
But something is still not right. With that ALT + 5 feature I see my 8th level code changing Song @1 to Song 51, which is the correct 5th place. And also when applied to Song (Anything) I get Song 7Anything), which is the correct 7th place. And yet in the main window I still see that Song @1 is below Song (Anything). How is that possible, if in Convert > Tag-Tag the 5th replacement is shown as >>5<<, and 7th is shown as >>5<<?

And yes, I have clicked that Column name twice, in order for the code to apply itself to the loaded up files


If it will be anything of convenience, I can upload somewhere set of files with proper names- the very one set that I use to test these codes

I do not think that a set of files will help.
It looks to me that you have found the correct expression already in Convert>tag-Tag.
What I cannot judge from the distance is what went wrong in the column definition.
I am sure that you will find out locally.

The problem seem to be this: it is important also what character follows the replaced [sorted] character

If I add to the files Song @A, then it is placed where it should be: before Song {Anything}. Because Song @A is translated to Song 5A while Song {Anything} is translated to Song 7Anything}. But why does Song @1 which is translated to Song 51 is placed after Song {Anything} which is translated to Song 7Anything} - when at the same time a file with a title 1 is before file with a title A? Is it because 1 and A are just single characters [strings consisting of 1 sign] while all of the previously cited exaple have something stuck to the right side of the replaced / sorted character?

When replacing you have to take care that the search string is not part of another replace string.
Also, I think that your nested search strings are hard to understand and to debug. You can use a single $replace() with several pairs which are executed left to right.

If I use something as simple as

$replace(%TITLE%,'[',1,'+',2,'{',3,'(',4,'#',5)

then the order I get is OK but with one little exception. I have

Song
Song 1X
Song [Anything]
Song #3
Song 2``

instead of

Song
Song [Anything]
Song #3
Song 1X
Song 2

So the problem is the X [or whatever is stuck to a digit]

There are of course other rules that were taken out from this simplified example- but this example shows exactly what I currently am not able to do: to put at 6th place [i.e. at the "end"] a combination of a digit with something following it in a adjacent matter

If I read that correctly, the replace function leads to
Song
Song 1X
Song 1Anything
Song 53
Song 2``

I would therefore assume that the order should be
Song
Song 1Anything
Song 1X
Song 2``
Song 53
Could it be that

too many

Yes, the rules are many - and this whole issue with them gives me a headache everytime I reluctantly try to take care of this. Or to be precise the rule is just one and it is just the order of signs that I want to enforce. The order [now set for good] does not change depending on files that I work on

My 2 main programs for handling audio files, the Mp3tag and FreeCommander, use different set of rules for sorting these characters. So this tells me two things: that I have a dichotomy that further brings chaos into lists of files [and that statement is backed by empiric issues, to which I had to start to use a certain workaround]; and that a change of display order is somewhat doable


I think I was wrong the last time, so please disregard the previous post. But once again I will try to report this right. And coming up with a limited yet most informative set of examples I now see clearly what is the problem

So I have now sort order like this

Song
Song 1
Song [Abc]
Song 1Abc]
Song 2
Song 2 ``
Song 2X
Song #3
Song Abc

but need to have

Song
Song [Abc]
Song 1
Song 1Abc]
Song 2
Song 2 ``
Song 2X
Song #3
Song Abc

but with a simple code like that

$replace(%TITLE%,'[',1,'+',2,'{',3,'(',4,'#',5)

it is simply impossible. Because this code correctly changes Song [Abc] into Song 1Abc]. And yes, that "virtual" 1 is placed in accordance with the rules imposed by that code- but not with my wishful overall rule that [ should go before any digit, because with this method the [ itself is changed into a digit [and so all digits, real and "temporary" ones are then sorted as digits]

So if I am not mistaken, when using $replace my goal is unreachable

Or you modify you replacement rules so that you definitely get the right order.
E.g. I do not see the "0" (or "zero(w)", sorry, had to make that pun) in the replacement pairs.
It does not work if the replaced character is later used as proper character in the sorting. You would have to think of an unused character which is high up in the sorting order, e.g. the 0 or the underscore. Or whatever is fine for you. It is not a problem of the $replace() function but a problem or your particular preferences and your applied concept.