Sort name with number descending and letters ascending

Is there any way that I can sort files within folder by name so that numbers are listed in descending order and letters in ascending order?

I want files with filename starting with "2023....." above files with filename starting with "2022...".
Simultaneously I want files starting with "A..." above files starting with "B..."

Thanks

Try sorting by this evaluator column (requires Opus v13):

if(!RegEx(name,"^\d.*")) return name;

newname = RegExS(name,"0","a","1","b","2","c","3","d","4","e","5","f","6","g","7","h","8","i","9","j");

newname = RegExS(newname,"a","9","b","8","c","7","d","6","e","5","f","4","g","3","h","2","i","1","j","0");

return newname;

Paste this

XML
<?xml version="1.0"?>
<evalcolumn align="0" attrrefresh="no" autorefresh="no" foldertype="all" keyword="t47486" maxstars="5" namerefresh="no" reversesort="no" title="t47486" type="0">yy = RegEx(name,&quot;.*?(\d+)\.(\d+)\.(\d+).*?&quot;,&quot;\1&quot;);
mm = RegEx(name,&quot;.*?(\d+)\.(\d+)\.(\d+).*?&quot;,&quot;\2&quot;);
dd = RegEx(name,&quot;.*?(\d+)\.(\d+)\.(\d+).*?&quot;,&quot;\3&quot;);

if (yy&lt;100) yy += 2000;

return (yy + &quot;-&quot; + mm + &quot;-&quot; + dd) as date;

// https://resource.dopus.com/t/best-way-to-sort-by-date-which-is-part-of-filename/47486/15</evalcolumn>

into Preferences / File Display Columns / Evaluator Columns.

Häh? Ich versteh nur Bahnhof :grimacing:

How is this a regular expression, if any?
RegExS, OK but understanding its syntax needs some minutes or so :rofl:

Yep, gotta have your regex A-levels for this beaut :wink:

1 Like

Hi Thanks very much for this, it's definitely on the right track, there are still some issues with results though, see example image

It might be easier to have a column that extracts the number (if any) from the start of the name, then do a multi-column sort on that (descending) and the name column (ascending). At least, I think that would create the order you want.

Thanks, where is a good place to start learning the Evaluator coding basics?

1 Like