home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
utility
/
pbaseiv.zip
/
P4DOS000.TIP
< prev
next >
Wrap
Text File
|
1991-12-16
|
3KB
|
88 lines
Just two short notes on Derek Houseworth's DS.BAT batch file
["Sort of a Directory," Star-Dot-Star, March 1991]. The
batch file displayed a directory listing sorted by name,
extension, size, date, or time.
1. The batch file adds three variables to the environment.
To avoid cluttering your environment, put commands at the
end of the batch file to remove the variables when it's
done [see LISTING 2 for a modified file].
2. Mr. Houseworth's pos=24 command for sorting by date
ignores years, so that `1-05-91' lists before `12-28-88'.
I prefer sorting by year, so I use pos=30 to do just
that.
Kenneth Metz, Jr.
Duncanville, Texas
Editor's note: Cleaning up the environment is always a good
idea. Many astute readers noticed that the date and time
sorts in DS.BAT err because the DIR command does not
normally produce dates and times that can be sorted
alphabetically. Starting the sort in column 30, as Mr. Metz
suggests, gets the year right but not the month or day.
After pondering this problem for a while, it dawned on me
that there's a different fix that causes the original DS.BAT
to sort everything correctly (provided you don't mind seeing
dates and times in a slightly different format). The
COUNTRY= statement in CONFIG.SYS lets you change the way
dates and times are printed to match different countries'
conventions, and use easily sortable conventions, such as
Sweden, France, and Canada's `91-07-19' dates.
To use DS.BAT as is, include the statement
COUNTRY=002,,C:\DOS\COUNTRY.SYS on one line in your
CONFIG.SYS, adjusting the path in C:\DOS\COUNTRY.SYS if
needed. The syntax may vary among DOS versions, so consult
your manual for the right country code.
This trick will work for another nine years, until the year
wraps to `00'. After that, we'll have to come up with yet
another fix for this batch file--or use a utility that looks
at the entire date. Bill Claff's ShareWare program !
(pronounced bang!) is one such utility; you may want to look
for it on your favorite BBS or on-line service.
Postscript: Since this tip was published, MS-DOS 5.0 came
out; it solves the problem once and for all with a built-in
sort switch in the DIR command. The /O:<order> switch lets
you sort a listing forward or backward by date and time,
size, name, and extension. Thus, DS.BAT is only of use to
you if you haven't upgraded to DOS 5.
DS.BAT Modified to Clean Up Environment
(Use Alt-F to copy to file)
---- BEGIN LISTING ----
@echo off
set pos=1
set fil=%1
set order=%2
if not "%2"=="" goto FIND
set order=%1
set fil=*.*
:FIND
if "%order%"=="N" set pos=1
if "%order%"=="n" set pos=1
if "%order%"=="E" set pos=9
if "%order%"=="e" set pos=9
if "%order%"=="S" set pos=14
if "%order%"=="s" set pos=14
if "%order%"=="D" set pos=24
if "%order%"=="d" set pos=24
if "%order%"=="T" set pos=34
if "%order%"=="t" set pos=34
dir %fil% | sort /+%pos% | more
set pos=
set file=
set order=
---- END LISTING -----
Title: A Better Sort of Sort
Category: DOS
Issue date: Jul 1991
Editor: Brett Glass
Supplementary files: NONE