home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / pbaseiv.zip / P4DOS000.TIP < prev    next >
Text File  |  1991-12-16  |  3KB  |  88 lines

  1. Just two short notes on Derek Houseworth's DS.BAT batch file
  2. ["Sort of a Directory," Star-Dot-Star, March 1991]. The
  3. batch file displayed a directory listing sorted by name,
  4. extension, size, date, or time.
  5.  
  6. 1. The batch file adds three variables to the environment.
  7.    To avoid cluttering your environment, put commands at the
  8.    end of the batch file to remove the variables when it's
  9.    done [see LISTING 2 for a modified file].
  10.  
  11. 2. Mr. Houseworth's pos=24 command for sorting by date
  12.    ignores years, so that `1-05-91' lists before `12-28-88'.
  13.    I prefer sorting by year, so I use pos=30 to do just
  14.    that.
  15.  
  16. Kenneth Metz, Jr.
  17. Duncanville, Texas
  18.  
  19. Editor's note: Cleaning up the environment is always a good
  20. idea. Many astute readers noticed that the date and time
  21. sorts in DS.BAT err because the DIR command does not
  22. normally produce dates and times that can be sorted
  23. alphabetically. Starting the sort in column 30, as Mr. Metz
  24. suggests, gets the year right but not the month or day.
  25.  
  26. After pondering this problem for a while, it dawned on me
  27. that there's a different fix that causes the original DS.BAT
  28. to sort everything correctly (provided you don't mind seeing
  29. dates and times in a slightly different format). The
  30. COUNTRY= statement in CONFIG.SYS lets you change the way
  31. dates and times are printed to match different countries'
  32. conventions, and use easily sortable conventions, such as
  33. Sweden, France, and Canada's `91-07-19' dates.
  34.  
  35. To use DS.BAT as is, include the statement
  36. COUNTRY=002,,C:\DOS\COUNTRY.SYS on one line in your
  37. CONFIG.SYS, adjusting the path in C:\DOS\COUNTRY.SYS if
  38. needed. The syntax may vary among DOS versions, so consult
  39. your manual for the right country code.
  40.  
  41. This trick will work for another nine years, until the year
  42. wraps to `00'. After that, we'll have to come up with yet
  43. another fix for this batch file--or use a utility that looks
  44. at the entire date. Bill Claff's ShareWare program !
  45. (pronounced bang!) is one such utility; you may want to look
  46. for it on your favorite BBS or on-line service.
  47.  
  48. Postscript: Since this tip was published, MS-DOS 5.0 came
  49. out; it solves the problem once and for all with a built-in
  50. sort switch in the DIR command. The /O:<order> switch lets
  51. you sort a listing forward or backward by date and time,
  52. size, name, and extension. Thus, DS.BAT is only of use to
  53. you if you haven't upgraded to DOS 5.
  54.  
  55. DS.BAT Modified to Clean Up Environment
  56. (Use Alt-F to copy to file)
  57.  
  58. ---- BEGIN LISTING ----
  59. @echo off
  60. set pos=1
  61. set fil=%1
  62. set order=%2
  63. if not "%2"=="" goto FIND
  64. set order=%1
  65. set fil=*.*
  66. :FIND
  67. if "%order%"=="N" set pos=1
  68. if "%order%"=="n" set pos=1
  69. if "%order%"=="E" set pos=9
  70. if "%order%"=="e" set pos=9
  71. if "%order%"=="S" set pos=14
  72. if "%order%"=="s" set pos=14
  73. if "%order%"=="D" set pos=24
  74. if "%order%"=="d" set pos=24
  75. if "%order%"=="T" set pos=34
  76. if "%order%"=="t" set pos=34
  77. dir %fil% | sort /+%pos% | more
  78. set pos=
  79. set file=
  80. set order=
  81. ---- END LISTING -----
  82.  
  83. Title: A Better Sort of Sort
  84. Category: DOS
  85. Issue date: Jul 1991
  86. Editor: Brett Glass
  87. Supplementary files: NONE
  88.