Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dir

4 views
Skip to first unread message

mad

unread,
Jul 20, 2009, 8:37:21 AM7/20/09
to
I have the following problem: When I use "Dir /B" I get the foolowing
results in an example:
----
1.jpg
10.jpg
11.jpg
12.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg
------

However I would like to have the following result:
1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg
10.jpg
11.jpg
12.jpg

How can I sort the text to achieve this?

Best regards,

Hartwig

Ted Davis

unread,
Jul 20, 2009, 8:53:40 AM7/20/09
to

Short answer: you can't.

Long answer: there is a SORT utility in the GnuWin32 CoreUtils collection
that will sort according to numerical value.

Using your file names,

DIR /b produced

1.jpg
10.jpg
11.jpg
12.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg

(as expected) and

dir /b *.jpg | c:\bin\sort -g

produced

1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg
10.jpg
11.jpg
12.jpg

The CoreUtils are free and open source at
<http://gnuwin32.sourceforge.net/packages/coreutils.htm>

In future, it would be advisable to use leading zeros on numbered files,
at as many digits in all as the largest number ever to be used.

--
T.E.D. (tda...@mst.edu)

mad

unread,
Jul 20, 2009, 3:57:05 PM7/20/09
to
> T.E.D. (tda...@mst.edu)- Hide quoted text -
>
> - Show quoted text -

thanks very much!!

Hartwig

ras...@highfiber.com

unread,
Jul 23, 2009, 11:05:07 PM7/23/09
to

Use 4DOS instead of COMMAND.COM. This sorting format -- logical,
rather than ASCIIbetical -- has been the default in 4DOS since the
late 1980s.

-------------
D:\TEST>ver /r

4DOS 8.00 MS-DOS 5.50
4DOS Build 200 (Feb 27 2009)
DOS Revision A; DOS is in HMA

D:\TEST>dir /b


1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg
10.jpg
11.jpg
12.jpg

D:\TEST>
-------------

Charles Dye

0 new messages