Solved How to use dir to diplay filenames in numerical order?

September 27, 2014 at 09:26:20
Specs: Windows 7
I tried using dir /b /on >m.txt to get my files listed in number order but I get this:

a75.jpg
a770.jpg
a78.jpg
a8000.jpg
a88.jpg

I wanted :

a75.jpg
a78.jpg
a88.jpg
a770.jpg
a8000.jpg

Can this be done?


See More: How to use dir to diplay filenames in numerical order?

Report •

#1
September 27, 2014 at 10:11:54
use DIR /O (the letter 'O', not zero), followed by one of these addition switches:

http://jpsoft.com/help/dir.htm#o


Report •

#2
September 27, 2014 at 15:42:13
✔ Best Answer
The dir/o:n sorts alphabetically. When numbers are part of the file name it treats them the same way but a number has to treated as a whole and not digit by digit--770 is more than 78 but not when sorted alphabetically. I don't think the DIR command has any way to sort them the way you want.

However if they were named this way:

a0075.jpg
a0078.jpg
a0088.jpg
a0770.jpg
a8000.jpg

you'd get them listed in the order you wanted.


Report •

#3
September 27, 2014 at 16:39:00
I often put leading zeros into file names for that reason, if I think
the number of files might go to higher orders of magnitude.

-- Jeff, in Minneapolis


Report •

Related Solutions

#4
September 27, 2014 at 16:50:36
Yeah, pictures from phones and digital cameras often have excruciatingly long file names and I usually rename then sequentially too.

message edited by DAVEINCAPS


Report •

Ask Question