Hey @mrpasini, that is a nice one and I think it deserves the award "Most elegant solution" in the sense that it gets the job done without adding complexity. Also using the extension as a second key is a nice option, if desired.
That being said, the ST has one advantage: Since it is using a regular expression to determine the search key (the part in-between the slashes) it is more flexible than counting the key delimiter positions.
This allows you to handle also cases – for example – with a varying number of "fields". Let's say you have this:
03.longclip.jpg
clip 03.jpg
clip.jpg
03 clip.jpg
03.jpg
Water 06.wav
Water 01.wav
clip.03.jpg
03.clip.jpg
where you want to treat everything up to the last dot as the filename root.
This can be easily achieved by making the regex greedy, that is, changing it from ([^.]+)
to (.+)\.
Sorted output:
03.jpg
03 clip.jpg
03.clip.jpg
03.longclip.jpg
clip.jpg
clip 03.jpg
clip.03.jpg
Water 01.wav
Water 06.wav
I tried to duplicate this with the sort
program but I couldn't find a way to make it count the positions from the end of the string. Something like -k-2,-2
doesn't work.