Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 'dir' command, Order By Name AND <something>

We can see in a directory files ordered by Name in Windows Explorer.

If I try the same thing in the Windows command prompt it orders by name differently - correctly:

dir *.jpg /ON /B

cubierta.jpg
pag00.jpg
pag06.jpg
pag08.jpg
pag09.jpg
pag100.jpg
pag101.jpg
pag102.jpg
pag103.jpg
pag104.jpg
pag105.jpg
pag106.jpg
pag107.jpg
pag108.jpg
pag109.jpg
pag11.jpg, etc, etc, etc, ...

Is there a way to get dir to order by Name where it reads the numbers as a human would do?

like image 908
ian_scho Avatar asked Oct 28 '08 11:10

ian_scho


1 Answers

Your best option (if possible) is to add enough leading zeros (two, in this case) to your smaller numbers so that the sort does come out as expected.

like image 83
Doug L. Avatar answered Nov 15 '22 13:11

Doug L.