Brackets display order - [ ] ( ) { }

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?

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 :slight_smile:

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

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:
http://help.mp3tag.de/options_export.html
"$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).

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 :slight_smile:


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}

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'?
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?

See Tools>Options>Export

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'

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 Tools > Options > Export > Export file name
the location / name of file is changed

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)?

Yes: that what you enter in Tools>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.

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

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

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

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

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

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 :slight_smile:

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

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?

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:

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.

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.


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

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

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