home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-02-26 | 52.5 KB | 1,215 lines |
- ------------------------------------------------------------------------
-
- SD: MS-DOS Sorted Directory Utility Program
- Version 5.4 (C) 01-Feb-87 by John F. Stetson
- 42 Tivoli Lake Ct., Silver Spring, Md. 20906
-
- ------------------------------------------------------------------------
-
- System Requirements
-
- ------------------------------------------------------------------------
-
- SD.COM is a sorted directory utility program which operates under the
- Microsoft Disk Operating System Version 2.0 and above. There are
- versions of the program tailored for the following types of systems:
-
- IBM-PC Systems and Compatibles (SDPC.COM)
-
- Zenith Z-100 Series Systems (SD100.COM)
-
- Generic MS-DOS Systems (SDGEN.COM)
-
- These files, together with this documentation file, are distributed in
- the form of an archive file called SD54.ARC which can be found on a
- variety of Computer Bulletin Board systems or obtained directly from the
- author, as described below. The appropriate .COM file should be renamed
- to SD.COM and placed in the root directory of the system disk, for
- normal use.
-
- This version of the program requires less than 8k bytes of disk space
- and about 16-24k bytes of memory during execution, depending on the
- number of files in the directories being processed.
-
- Support is provided for IBM-PC compatible monochrome monitors, and both
- CGA and EGA color monitors. Support is provided for both monochrome and
- color Z-100 monitors.
-
- Current program limitations are 100 total directories when processing
- global subdirectories and about 2000 files per directory.
-
- ------------------------------------------------------------------------
-
- Design Philosophy
-
- ------------------------------------------------------------------------
-
- SD provides more information than the resident MS-DOS DIR command about
- the files on a disk, and allows the user to select, sort, format, and
- display the information in a variety of ways. This is accomplished by
- specifying a pattern name to select the desired files and by specifying
- any of a variety of command lines "switches" which allow you to modify
- the behavior of the program. The switch names have been selected using
- letters, as much as possible, so that it is easier to associate the
- function of a switch with its name. In addition, the default switch
- values have been carefully chosen to reflect their most common use, and
- for compatibility with the standard DIR command.
-
- Although the program is relatively small, it is possible to use it in an
- almost infinite variety of ways by using the switches in different
- combinations. A significant amount of effort has gone into optimizing
- the performance of the program, due to the number of times it is
- typically used. The program is designed to be as transparent as
- possible in normal operation, and does not impose itself between the
- user and the operating system. This allows both novice and
- sophisticated users to use it in the way that best meets their needs.
-
- The program defaults to using the BIOS (rather than DOS) for console
- output, which results in noticeably faster displays. Command output can
- still be redirected to an output file by using a special switch.
-
- Maximum possible use is made of the horizontal dimension of the screen
- to minimize the loss of previously displayed data by screen scrolling.
-
- Support is provided for a variety of file selection attributes.
-
- Support is provided for a variety of screen display formats with varying
- amounts of detailed file information displayed.
-
- A variety of user customizable command line switches and screen field
- display colors are also supported.
-
- Every effort has been made to keep the size of the program to a minimum,
- for efficient use on floppy disk based systems. However, many of the
- capabilities of both MS-DOS and this program are only fully realized
- when using large hard (fixed) disks with hierarchical directory
- structures to organize files.
-
- ------------------------------------------------------------------------
-
- Modes of Operation
-
- ------------------------------------------------------------------------
-
- SD is a versatile program that can be used in a variety of ways:
-
- The most common use is to simply display information about files (and
- subdirectories) in a single (usually the current) directory. Most of
- the sort field switches are used in this mode.
-
- The program can be used to search or scan all (or a subset) of the
- directories on a disk for one or more files or directories which meet
- the specified criteria. The /g switch is used in this mode.
-
- The program can be used to display detailed information about the
- structure of a disk and about the location of files on the disk. The /i
- or /p and /1 switches are used in this mode.
-
- The program can be used to create an output file by redirecting console
- output which may be subsequently used as input to another program. The
- /r switch is used in this mode.
-
- ------------------------------------------------------------------------
-
- Command Line Syntax
-
- ------------------------------------------------------------------------
-
- The complete form of the DOS command line to run the program is:
-
- D>sd [drive:][path][filespec] [/switches] [>[>]device/file]
-
- In most cases, only one or two parameters are specified, so the command
- syntax isn't as formidable as it may appear at first. Each of the
- command line parameters is optional (as the [] characters indicate) and
- may be used together in any combination or order. Spaces may also be
- freely used at any point to improve readability. The various command
- line parameters are described below:
-
- [drive:]
-
- This parameter specifies the name of the disk drive to be processed.
- Typical drive letters are A: or B: for floppy disks and C: for a hard
- disk on the IBM-PC/XT or E: on the Zenith Z-100. RAM (memory) disks
- installed as device drivers may also be specified, and typically have
- the highest drive letter currently in use by the system assigned to
- them. If no drive letter is specified, the currently logged-in drive
- (shown in the DOS prompt) is used.
-
- [path]
-
- This parameter specifies the path through the hierarchical directory
- structure to the desired directory which contains the files to be
- processed. The general form of the path parameter is shown below:
-
- [path] = [\][directory][\directory]...[\directory][\]
-
- The path name may simply be the name of the root directory (\), or the
- same of a subdirectory in the root directory. The standard DOS . and ..
- directory names may be used to refer to the current and parent
- directories, respectively. If a path is not specified, the current
- directory on the specified disk drive is used.
-
- [filespec]
-
- This parameter specifies which file names are to be selected for
- processing from the previously specified directory (if any). A complete
- (unambiguous) file name may be specified, or an ambiguous file name,
- containing 'wildcard' characters (? or *) may be specified to select
- several files. Either the file name (first 8 characters) or the file
- extension (last 3 characters) or both may be completely omitted. In
- these cases, wildcard characters are automatically used to match all
- possible file names in the selected directory. You may specify leading
- characters of the file names you wish to match, omitting the trailing
- characters of the name, the period delimiter, and the file extension. In
- this respect, SD processes file specifications differently than DIR.
-
- For example: sd abc is equivalent to: dir abc*.*
-
- [/switches]
-
- This parameter specifies one or more 'switch' or option values which
- modify the operation of the command. All switches are optional and may
- be specified before the drive, path, and filespec, after them, or both
- before and after. An almost infinite variety of different processing
- modes may be selected by combining the various switches together in
- different combinations. Each switch has a default value, which has been
- carefully selected to represent the most frequently used option, for
- most users. Specifying a switch overrides or 'toggles' the value of that
- command option. A special 'patch' area has been provided at the
- beginning of the SD.COM file so that sophisticated users can tailor the
- default switch settings to their needs. If a default switch value is
- modified, specification of that option will toggle the option back to
- its original state, if appropriate. Detailed descriptions of all
- switches are given below.
-
- [>[>]device/file]
-
- This parameter is actually a standard feature of DOS called redirection
- of output to the 'standard output' (STDOUT) device. This allows the
- console output generated by the program to be transmitted to either
- another device (usually the printer device: PRN), or to a disk file. By
- redirecting the output of the command to a file, you can later use the
- file as input to a word processor, disk catalog system, etc. If this
- parameter is specified, the /r switch must also be specified so that the
- program will know to use the standard DOS console output services
- instead of those in the BIOS, which cannot be redirected.
-
- Console output may be paused by typing any character and is restarted
- when another character is typed. If /q (or /r) is not specified, output
- is paused every time the screen fills. Pressing ESCAPE (preferred),
- Control-C, or Control-Break will terminate the program immediately.
-
- ------------------------------------------------------------------------
-
- Command Line Switches
-
- ------------------------------------------------------------------------
-
- If a switch value other than those described below (//, for example) is
- specified, a message is displayed and the user is given the choice of
- exiting back to DOS by pressing the ESCAPE key, or receiving a screen of
- help information, if any other key is pressed. The preferred method of
- displaying command help information is by means of the /? switch.
-
- ------------------------------------------------------------------------
-
- File Attribute Selection Switches
-
- ------------------------------------------------------------------------
-
- Syntax: /s[attr-switch]...[attr-switch]
-
- /s - Select all directories and files
- /sd - Select only Directories (no files)
- /sf - Select only Files (no directories)
- /sa - Select files with the Archive attribute
- /sr - Select files with the Read/Only attribute
- /sh - Select files with the Hidden attribute
- /ss - Select files with the System attribute
-
- These switches are used to further restrict which files are selected (in
- addition to any filespec) based on the attributes of the files.
-
- If a /s switch is not specified, the default is to select all of the
- subdirectories and files in the specified directory, except those with
- either the Hidden or System attribute. This includes files with no
- special attributes, the Archive attribute, and/or the Read/Only
- attribute. This is the same method of attribute selection used by the
- DIR command, except that the . (current) and .. (parent) directory
- entries which occur in all directories other than the root directory are
- not displayed.
-
- If /s is specified with no other attribute switch, Hidden and System
- files are also selected, thus providing the most information.
-
- If /sd is specified, all and only the subdirectories in the specified
- directory are selected.
-
- If /sf is specified, all and only the files with no attributes, the
- Archive attribute and/or the Read/Only attribute are selected. The /sh
- and/or /ss switches may be added to /sf, if desired.
-
- If a /sa, /sr, /sh, or /ss switch is specified by itself, all and only
- the files with the specified attribute are selected. These switches may
- also be combined in any order and the intervening /s switch(es) omitted:
-
- D>sd c:\dir/sa/sr - OR - D>sd c:\dir/sar
-
- When multiple /s switches are specified, the effect is 'additive'; i.e.
- for the example above, all files with either the Archive or Read/Only
- attribute will be selected from the specified directory.
-
- Specification of any /s switch(es) other than /sd causes an additional
- 'totals' line to be displayed which summaries the number of files which
- have each of the requested attributes.
-
- One difference between SD and CHKDSK is that CHKDSK considers a disk
- volume label to be a "hidden file", whereas SD does not.
-
- ------------------------------------------------------------------------
-
- Description of File Attributes
-
- ------------------------------------------------------------------------
-
- The Archive attribute is automatically set by DOS when a file is created
- or updated, and is reset by the BACKUP program and other similar
- programs when the file is backed up from a hard disk to a floppy disk.
-
- The Read/Only attribute is supposedly used to mark a file as being
- "Read/Only"; it cannot be written to by standard MS-DOS system
- functions. However, DOS V2 allowed FCB style writes to files with the
- Read/Only attribute; only Handle style writes were precluded. This
- oversight was apparently corrected starting with DOS V3. The ATTRIB
- command introduced in DOS V3 allows the Archive and Read/Only file
- attributes to be set and reset from the DOS command level.
-
- The Hidden attribute "hides" a file from normal directory searches (such
- as the DIR command) and is sometimes used by copy protection schemes.
- However, any program which is capable of issuing the proper DOS system
- call can find any "hidden" files, just as SD does.
-
- The System attribute identifies a "system" file and also precludes the
- file from being found by normal directory searches. The standard DOS
- System files are the BIOS and DOS .COM files which are always the first
- two files on a bootable system disk. COMMAND.COM is not identified as a
- system file, since many programs need to be able to locate it in order
- to execute it as a "child process".
-
- Although not provided as an intrinsic part of DOS, there are a variety
- of utility programs available which can set and reset any of the file
- attributes mentioned above. This is normally done using the DOS INT 21H
- function 43H to change a file's attributes. It is also possible (and
- more risky!) to directly modify the disk sector containing the file's
- directory information, using DEBUG or other sector level disk editing
- utility programs.
-
- ------------------------------------------------------------------------
-
- File Selection By Date
-
- ------------------------------------------------------------------------
-
- Syntax: /@[+/-][days][+/-]
-
- The /@ switch is used to select files based on their age (the date the
- file was created or last updated). Since dates are specified relative to
- the current system date (normally set by the DATE command or real time
- clock at boot time), it is essential that the system date be set
- correctly in order for this feature to work properly.
-
- Files may be selected which are exactly the specified number of days
- old, or either newer (+) or older (-) than the specified number of days.
- The number of days specified may range from 0 to 9999, syntactically,
- but cannot be so large as to pre-date January 1, 1980, which is when the
- universe was created (according to DOS!).
-
- Think of the date specification process in two steps: go back the
- specified number of days and then find the files written before (-), on,
- or after (+) that date.
-
- For example:
-
- /@ select files written today (days=0)
- /@1+ select files written during last 2 days
- /@7 select files written exactly one week ago
- /@+30 select files written during the past month
- /@-365 select files written more than a year ago
-
- The +/- may be specified either before or after the number of days.
-
- ------------------------------------------------------------------------
-
- Sort Field Selection Switches
-
- ------------------------------------------------------------------------
-
- Syntax: /sort-switch[+/-]
-
- /a - Sort by file Allocation unit (cluster #)
- /b - Sort by file size in Bytes
- /d - Sort by (1) file Date and (2) time
- /e - Sort by (1) file Extension and (2) name
- /f - Sort by (1) File Name and (2) extension
- /n - No sort - display entries in directory order
-
- These switches specify which fields are to be used as sort 'keys' when
- formatting the output information. These switches are all mutually
- exclusive; i.e. only one sort switch should be specified. If no sort
- switch is specified, the default is by file name and extension (/f).
-
- Sort switches may optionally followed by a + for an ascending sort or a
- - for a descending sort. The default sort direction is ascending for
- all sort switches except /d, which is descending.
-
- The /a switch sorts the file entries by the first allocation unit number
- (starting cluster number) of the file. This is simply the absolute
- location on the disk where the file is located. Although not normally
- used, this switch can be used to determine the actual order of the files
- on the disk, which is independent of their order in the disk directory,
- especially on a disk whose space has become "fragmented" by the creation
- and deletion of many files with differing sizes.
-
- The /b switch is used to find either the smallest or largest files on a
- disk, or to discover which file(s) have sizes which lie in a given
- range. This can be helpful when it is known that a file of a given size
- is missing from a disk, and it desired to find out its identity by
- examining the contents of another disk which does contain the file.
-
- The /d switch is a frequently used sorting option, especially when
- combined with the /2 or /1 switch. This allows either the newest or
- oldest files on a disk to be easily identified. Of course, the validity
- of this information is once again dependent on the correct setting of
- the system date at the time the files were written.
-
- The /e switch is helpful in identifying which, if any, files have
- "strange" file name extensions. Since most standard files have one of
- only a few possible types (extensions), such as .BAT, .COM, .EXE, etc.
- using this switch will separate out any non-standard file names.
-
- The /f switch simply sorts the selected directory entries by file name
- and extension, which is perhaps the most used sorting sequence. Once
- again, any "strange" file names will tend to collect at the beginning
- and end of the list, where they can be easily identified.
-
- The /n switch bypasses the sort process with the result that the file
- entries are displayed in the order they occur in the disk directory.
- This is helpful when examining a bootable disk to insure that the order
- of files is optimal (in the order they are needed during the boot
- sequence, and by frequence of use after boot-up). This is the same order
- of file names as that displayed by the DIR command.
-
- ------------------------------------------------------------------------
-
- Output Format Control Switches
-
- ------------------------------------------------------------------------
-
- Syntax: /output-switch ... /output-switch
-
- These switches are used to specify the appearance and format of the
- generated output and other miscellaneous functions. The switches fall
- into several categories which are described separately.
-
- ------------------------------------------------------------------------
-
- Help Information Switch
-
- ------------------------------------------------------------------------
-
- The /? switch causes program help information to be displayed. This
- includes a summary of the command line syntax and available switches.
-
- ------------------------------------------------------------------------
-
- Output Column Switches
-
- ------------------------------------------------------------------------
-
- The /1, /2, /4, and /6 switches specify the number of output columns
- and, inversely, the amount of file information displayed:
-
- /1 - 1 column - path, file name, size, date, time, starting cluster,
- starting sector (with /p), and attributes
-
- /2 - 2 columns - file name, size, date and time
-
- /4 - 4 columns - file name and size
-
- /6 - 6 columns - file name only
-
- A larger number of columns allows more files to be displayed on the
- console screen at one time, at the cost of losing some of the detailed
- file information. A smaller number of columns allows more detailed file
- information to be displayed, at the cost of only being able to display a
- limited number of files. All of these switches are mutually exclusive;
- only one should be specified. The default switch is /4.
-
- If the /1 switch is specified, the output information begins with the
- specified path name. This can be useful when used as input to a disk
- catalog program (when used with the /v switch to get the volume label).
-
- Subdirectory entries (normally found in the root directory) are shown
- with special screen attributes, for emphasis. This is especially
- helpful when using the /6 switch, since there isn't room for the <Dir>
- indicator (directory names may be up to 11 characters long, just like
- file names).
-
- The time a file was last written to is only accurate to a resolution of
- 2 seconds; all values will have an even number of seconds. Files
- created with early versions of DOS may not have either a date or time
- stamp. In this case, these fields will appear as periods.
-
- Each file attribute (if any) is denoted by a letter:
-
- A - Archive R - Read/Only H - Hidden S - System
-
- ------------------------------------------------------------------------
-
- Output Toggle Switches
-
- ------------------------------------------------------------------------
-
- The next group of switches are all 'toggles'; i.e. their default state
- is 'off' and they are toggled 'on' when specified. These may be used
- together in many different combinations.
-
- /c - Clear the console screen before displaying output
- /g - Perform Global subdirectory processing
- /h - Display output sorted Horizontally
- /i - Display Information summary
- /k - Display memory and disk space in Kbytes
- /l - Generate file name List
- /m - Display system version and Memory information
- /p - Display disk Parameter information
- /q - Quick output (no pauses when the console screen fills)
- /r - Generate output which is suitable for Redirection
- /t - Display only the Totals output lines
- /v - Display disk Volume label and creation date & time
-
- The /c switch causes the console display screen to be cleared before any
- output is displayed.
-
- The /g switch requests global subdirectory processing. All other
- switches operate as usual. After the specified target directory
- (usually, but not necessarily, a root directory) is processed, all
- subdirectories below that directory are processed in alphabetic order.
- After all directories have been processed, a grand totals line for all
- of the directories and files is displayed, followed by a grand totals
- line for file attributes (if a /s switch was specified).
-
- The /g switch has a variety of uses. It can be used to simply display
- the total number of directories, files, etc. on a disk, when combined
- with the /t switch. It can be used to locate any and all occurrences of
- a file anywhere on a disk with a complex directory structure by simply
- specifying a file name. However, if a fully qualified (unambiguous)
- file name is specified and you have a resident "data path" type utility
- program installed, you may see spurious copies of the specified file in
- all directories! This can occur because these types of programs
- intercept the DOS directory search functions and redrive them using
- additional directory paths. In this case, simply make the file name
- ambiguous by inserting one or more * or ? characters. Another
- interesting use is to specify the /sd switch, which will display all of
- the directories on the disk below the specified directory.
-
- The /h switch causes the file entries to be displayed horizontally
- rather than vertically (according to the sort option specified). This
- is handy when more than a screen's worth of output is generated, so that
- the sequence of file entries is continuous after the screen scrolls.
-
- The /i switch causes a summary of information about the specified disk
- to be displayed. This is equivalent to specifying the /m/v/p/s/t
- switches. The only other switches which make sense with /i are /c, /g,
- /k, /q, and /r.
-
- The /k switch requests that system memory and disk space information be
- displayed in units of kilobytes (1024 bytes), rather than the default
- units of bytes. In addition, these values are rounded upward, taking
- into account the allocation unit (cluster) size for the specified disk.
- System memory values are simply rounded to the next higher kilobyte. Use
- of the /k switch will reveal the actual amount of disk space used by
- each file, rather than the normal file size, which may be much less. For
- disks with a cluster size less than 1024 bytes (primarily RAMDISKs),
- specifying the /k switch may cause the displayed number of bytes used to
- actually exceed the total space used on the disk. This is due to the
- cumulative effect of adding a series of rounded values.
-
- The /l switch will cause a list of file names (only) to be generated.
- All other output (file information and totals lines) is suppressed. This
- switch is normally used with the /sf switch (to suppress any
- directories), and the /r switch to redirect the output to a file for
- processing by another program. /l can also be combined with the digit
- switches to simply cause the suppression of the totals lines. Since any
- embedded spaces are removed, the file names are ready to be operated on
- by copy commands which might be generated automatically by another
- program. The /h, /i, /k, /m, /p, /t, and /v switches are not normally
- used with the /l switch.
-
- The /m switch will display the DOS system version and system memory
- usage: System Memory Used, Free, and the Total Available.
-
- The /p switch will display a variety of disk parameters from the BIOS
- Parameter Block (BPB) in the disk boot sector (if available), and other
- parameters obtained directly from DOS.
-
- The first line of BPB disk parameters contains:
-
- OEM Info - This field usually contains the Original Equipment
- Manufacturer's name (IBM, ZDS, etc.) and the DOS version used to format
- the disk (2.1, 3.2, etc.).
-
- Sectors/FAT - The number of sectors per File Allocation Table.
-
- Root Dir Size - The maximum number of entries in the disk's root
- directory.
-
- Total Sectors - The total number of sectors on the disk, including the
- Boot sector(s), FAT sectors, Root Directory sectors, and Data sectors.
-
- The second line of BPB disk parameters contains:
-
- FATs - The number of File Allocation Tables (usually 2).
-
- Reserved Sectors - The number of sectors reserved at the beginning of
- the disk for the boot sector, partition tables, etc.
-
- Sectors/Track - The number of sectors per track on the disk.
-
- Heads - The number of heads on a hard or floppy disk. Some RAMDISKs may
- have too many heads for their own good!
-
- Hidden Sectors - The number of sectors on a hard disk hidden from use by
- DOS when processing the current disk partition. This area on the disk
- may either contain partition information, or the data in another
- partition, depending on the partitioning scheme used.
-
- The line of DOS disk parameters contains:
-
- Media Byte - The media descriptor byte is used to describe the size and
- format of the disk media (Number of sides, Number of Tracks, Number of
- Sectors per Track). Some typical PC media bytes are:
-
- Media Byte Sides Tracks Sectors/Track Disk Type
- ---------- ----- ------ ------------- ---------
- FFH 2 8 40 5" floppy
- FEH 1 8 40 5" floppy
- FDH 2 9 40 5" floppy
- FCH 1 9 40 5" floppy
- F9H 2 15 80 5" floppy
- F8H - -- -- Hard Disk
-
- Although the media byte is used by the BIOS to determine the disk
- characteristics in certain cases, not all MS-DOS BIOS implementations
- use exactly the same media bytes for the same disk types. Two examples
- are the media bytes used for 8" floppy disks and 5.25" 96 TPI 80 Track
- 8/9 Sector/Track floppy disks, which are not uniformly supported with
- the same media byte in all BIOS or Device Driver implementations.
-
- Bytes/Sector - The number of bytes per sector on the disk.
-
- Sectors/Cluster - The number of sectors per cluster on the disk.
-
- Clusters - The total number of data clusters on the disk. This does not
- include the boot sector, FATs, or root directory. DOS uses 16 bit FAT
- entries if a disk has more than 4085 data clusters. This is indicated
- by the notation (16) after the number of clusters.
-
- Most MS-DOS and PC-DOS V1 disks do not have a BPB in the disk boot
- sector, so the BPB information isn't displayed in this case. Also, some
- RAMDISKs may not have a "boot sector" at all! Zenith Z-100 disks
- contain a partial BPB in the boot sector, so the second line of BPB
- information isn't displayed for these disks.
-
- If both /1 and /p are specified, both the starting cluster number and
- starting sector number for each file are displayed. See the section on
- Disk Space Allocation below for more information.
-
- The /q switch suppresses the console reads which normally occur when
- output information is about to scroll off the screen.
-
- The /r switch causes console output to go through DOS, rather than the
- BIOS. Although this usually slows down the output and suppresses the
- screen attributes (colors) normally used, this is necessary when the
- need arises to redirect the output to a file or device (printer) for
- subsequent processing.
-
- /r must be specified when either the DOS command line redirection symbol
- (>) is used or the Control-P printer echo function is used. The program
- normally displays a graphics vertical bar symbol to separate adjacent
- columns of output information. This is changed to the standard ASCII
- (|) character if redirection is requested. Specification of the /r
- switch causes the /q switch to be turned on automatically.
-
- The /t switch suppresses the display of detailed information for
- individual files and directories and only displays the directory and
- disk space totals lines.
-
- The directory totals line includes the target directory path, the number
- of subdirectories, the number of files selected, and the total number of
- bytes in the selected files.
-
- The disk space totals line includes the space used, percent used, space
- free, and total space on the disk.
-
- The /t switch is used when you wish to compare the total number or size
- of files on two different disks or directories. If a difference is
- detected, other switches (such as /b or /d) can be used to determine
- which files are missing (or different).
-
- Another difference between SD and DIR is that SD counts directories and
- files separately; DIR includes both in its 'file' count.
-
- The /v switch causes the disk volume label (if any), and the volume
- creation date and time to be displayed. In addition, the current day of
- the week, date, and time are displayed.
-
- ------------------------------------------------------------------------
-
- DOS Disk Space Allocation
-
- ------------------------------------------------------------------------
-
- Disk space for files is allocated in units called clusters which are
- composed of one or more physical disk sectors.
-
- Typical values of cluster sizes for standard disk types are shown below:
-
- Disk Type Sectors/Track Capacity Cluster Size FAT Size
- --------- ------------- -------- ------------ --------
- SS 48 TPI 8 160k 512 12
- SS 48 TPI 9 180k 512 12
- DS 48 TPI 8 320k 1024 12
- DS 48 TPI 9 360k 1024 12
- DS 96 TPI 8 640k 2048 12
- DS 96 TPI 9 720k 2048 12
- DS 96 TPI 15 1.2m 2048 12
- Hard Disk 17 10m 4096 12
- Hard Disk 17 20m 2048 16
- Hard Disk 17 30m 2048 16
-
- Most DOS disks use 512 bytes per sector, and with the 12 bit File
- Allocation Table entries prior to DOS V3 (4096 clusters), this requires
- that progressively greater cluster sizes be used to support larger
- storage devices. This can result in a substantial amount of wasted
- space for large capacity hard disks with many relatively small files.
- DOS V3 added support for 16 bit FAT entries which allows 65536 clusters
- to be used, thus allowing a much smaller cluster size to be used with a
- corresponding better utilization of disk space.
-
- The starting cluster number of a file is an index into the disk's File
- Allocation Table (FAT) which contains another index for the next cluster
- for the file, etc. until an end of file entry is reached. This
- technique allows disk space to be dynamically allocated and deallocated
- in an efficient manner. Therefore, the FAT contains the cluster-level
- information for each file, with the initial FAT index contained in the
- directory entry for the file.
-
- A somewhat more useful, although complex, entity is the starting logical
- sector number of a file. This is the absolute disk sector number where
- the file starts, and can be used as input to the DEBUG program to read
- and write absolute disk sectors for a file. This value can be
- calculated from the starting cluster number for the file using
- information contained in the BIOS Parameter Block (BPB) which is located
- in the disk boot sector (the first sector on the disk). Specifying the
- /p switch causes the boot sector to be read and if the /1 switch is also
- specified, the starting sector number for each file is displayed after
- the starting cluster number.
-
- Each MS-DOS disk contains the following data areas:
-
- Reserved (Boot) Sector(s) - usually 1 sector
-
- File Allocation Table(s) - usually 2 copies
-
- Root Directory Area - variable size, 32 bytes/entry
-
- Disk Data Area - space for files and subdirectories
-
- In order to calculate the starting sector number of a file, we must
- first calculate the sector number of the Disk Data Area:
-
- Logical Sector number of the Disk data area (LSD) =
-
- (Number of Reserved Sectors) +
-
- (Number of FATs) * (Sectors/FAT) +
-
- (32 * (Number of Root Dir. Entries) + Bytes/Sector - 1) / (Bytes/Sector)
-
- Starting Logical Sector number of a File (LSF) =
-
- LSD + (Starting Cluster Number - 2) * (Sectors/Cluster)
-
- Using the information displayed by the /p and /1 switches and the DEBUG
- program, it is relatively easy to examine (and change!) the information
- in the data areas described above, as well as any of the files on a
- disk. This should not normally be necessary, and is not recommended
- under normal circumstances. However, it can be educational and even
- helpful when attempting to recover data from a damaged disk.
-
- ------------------------------------------------------------------------
-
- IBM-PC EGA Switches and Support
-
- ------------------------------------------------------------------------
-
- /25 - Display 25 lines on EGA (PC's only)
- /43 - Display 43 lines on EGA (PC's only)
-
- The /25 and /43 switches change to the specified number of lines on the
- screen when using an EGA on a PC compatible system. The screen is
- automatically cleared and the screen remains set to this size when the
- program terminates. If an EGA is in use and the number of screen lines
- has already been changed to a value other than the default of 25, the
- program will use that value.
-
- If /c is specified, the entire screen is cleared using the current
- number of lines, which may be more or less than the standard 25.
-
- ------------------------------------------------------------------------
-
- Modifying the Default Switch Values
-
- ------------------------------------------------------------------------
-
- The default switch values may be altered by using the DEBUG program to
- modify the following bytes in the SD.COM file:
-
- Offset Switch Default Possible Value(s)
- ------ ------ ------- -----------------
- 0102 Sort 'F' 'A', 'B', 'D', 'E', 'F', 'N'
- 0103 Cols '4' '1', '2', '4', '6'
- 0104 /c 0 0, 1=Clear display screen
- 0105 /g 0 0, 1=Global subdirectories
- 0106 /h 0 0, 1=Horizontal output display
- 0107 /i 0 0, 1=Display Info summary
- 0108 /k 0 0, 1=Display space in Kbytes
- 0109 /l 0 0, 1=Generate file name List
- 010A /m 0 0, 1=Display system Memory usage
- 010B /p 0 0, 1=Display disk Parameters
- 010C /q 0 0, 1=Quick output (no pauses)
- 010D /r 0 0, 1=Allow output Redirection
- 010E /t 0 0, 1=Totals output lines only
- 010F /v 0 0, 1=Volume label information
-
- For example:
-
- D>DEBUG SD.COM (Load SD.COM into memory using DEBUG.COM)
- -E103 '2' (Change the default number of columns to 2)
- -E10F 01 (Display the volume label info as a default)
- -W (Write the modified file back to disk)
- -Q (Exit to DOS from DEBUG)
- D>sd (Execute the modified version of SD.COM)
-
- ------------------------------------------------------------------------
-
- Screen Color Selection
-
- ------------------------------------------------------------------------
-
- The default foreground and background colors (screen attributes) used
- for the following displayed output fields may be changed with DEBUG:
-
- File colors apply to individual disk file entries.
-
- Directory colors apply to individual directory entries.
-
- Separator colors apply to the separator characters which are used to
- divide the entry columns vertically.
-
- Text colors apply to the leading and trailing text lines.
-
- Normal colors apply to the normal state of the screen before and after
- SD.COM is executed. These colors should be changed to match the
- standard screen colors used, if they are other than white on black.
-
- For the IBM-PC:
-
- Offset Field Attribute Default Description
- ------ --------------- ------- -----------
- 0110 File Fore/Back Colors 7+16*1 White on Blue
- 0111 Directory Fore/Back Colors 0+16*2 Black on Green
- 0112 Separator Fore/Back Colors 4+16*0 Red on Black
- 0113 Text Fore/Back Colors 6+16*0 Brown on Black
- 0114 Normal Fore/Back Colors 7+16*0 White on Black
-
- 0115 File Mono Attributes 7+16*0 Normal Video
- 0116 Directory Mono Attributes 0+16*7 Reverse Video
- 0117 Separator Mono Attributes 7+16*0 Normal Video
- 0118 Text Mono Attributes 7+16*0 Normal Video
- 0119 Normal Mono Attributes 7+16*0 Normal Video
-
- 0 = Black, 1 = Blue, 2 = Green, 3 = Cyan
- 4 = Red, 5 = Magenta, 6 = Brown, 7 = White
-
- The PC version of SD.COM uses either the color or monochrome attributes
- specified at the offsets in the table above, based on the type of
- monitor being used.
-
- Once the desired foreground and background colors (attributes) have been
- selected for an output field, compute the field attribute byte using the
- formula: ATTRIBUTE = FCOLOR+16*BCOLOR, where FCOLOR and BCOLOR are the
- foreground and background colors (attributes), respectively.
-
- Intensified foreground colors corresponding to the 8 standard colors may
- be selected by adding 8 to the foreground color number. For example,
- specify foreground color (6+8)=14 to get a foreground yellow color
- instead of the unintensified brown. The blinking attribute may be
- selected by adding 8 to the background color number. However, use of
- this attribute is not recommended, since it may be distracting. For a
- monochrome monitor, selecting Blue on Black (1+16*0) will cause the
- output field to be underlined.
-
- For the Z-100:
-
- Offset Field Color Def.(Color) Def.(Mono)
- ------ ----------- ----------- ----------
- 0110 File Fore Color '7' White '7' White
- 0111 File Back Color '1' Blue '0' Black
- 0112 Directory Fore Color '0' Black '0' Black
- 0113 Directory Back Color '4' Green '6' Yellow
- 0114 Separator Fore Color '2' Red '7' White
- 0115 Separator Back Color '0' Black '0' Black
- 0116 Text Fore Color '6' Yellow '7' White
- 0117 Text Back Color '0' Black '0' Black
- 0118 Normal Fore Color '7' White '7' White
- 0119 Normal Back Color '0' Black '0' Black
-
- '0' = Black, '1' = Blue, '2' = Red, '3' = Magenta
- '4' = Green, '5' = Cyan, '6' = Yellow, '7' = White
-
- Two different sets of default colors are shown in the table above for
- color and monochrome monitors. As supplied, the Z-100 version of SD.COM
- is configured for a color monitor. For proper operation on the Z-100,
- an ALTCHAR.SYS file must exist in the root directory of the boot disk,
- and the file must contain the standard Z-100 graphics font symbols (or
- the graphics vertical bar separator will appear as a grave accent).
-
- ------------------------------------------------------------------------
-
- Generic MS-DOS Version
-
- ------------------------------------------------------------------------
-
- The generic MS-DOS version of the program should work on any computer
- system capable of running MS-DOS 2.0 or higher. Most of the standard
- features of the program are available with the following exceptions:
-
- The /c switch simply prints two blank lines, since there isn't a generic
- method of clearing the console screen.
-
- The /r switch is defaulted, since there is no generic method of sending
- data to the console through the BIOS.
-
- The console display screen is assumed to consist of 24 lines.
-
- There is no patch area for screen attributes (colors).
-
- ------------------------------------------------------------------------
-
- System Return Codes
-
- ------------------------------------------------------------------------
-
- The following return codes are set and may be checked
- for using the IF ERRORLEVEL statement in a .BAT file:
-
- 0 - One or more matching files were found.
- 1 - No matching files were found.
- 2 - Bad drive (doesn't exist or syntax error).
- 3 - Bad path (doesn't exist or syntax error).
- 4 - Bad file specification (syntax error).
- 5 - Bad date (too large or syntax error).
- 6 - Bad boot sector (too large or bad sector).
- 7 - Too many directories (when /g specified).
-
- For example:
-
- ECHO OFF
- sd %1 /r >nul
- IF ERRORLEVEL 2 ECHO Drive does not exist!
-
- ------------------------------------------------------------------------
-
- Examples of Use
-
- ------------------------------------------------------------------------
-
- A>sd
-
- Display the current directory of drive A.
-
- C>sd /?
-
- Display program help information.
-
- B>sd/d/6
-
- Display the current directory of drive B, sorted by descending date and
- time, using the six column format (file names only).
-
- D>sd c:\/ss/2
-
- Display only the system files in the root directory of drive C, using
- the two column output format.
-
- C>sd b:/t
-
- Display the totals information for the current directory of drive B.
-
- A>sd c:\/sd
-
- Display all of the subdirectories in the root directory of drive C.
-
- A>sd c:\/l/sf/r >files.dat
-
- Create a file called "a:files.dat" which contains a sorted list of all
- files (no directories) in the root directory of drive C.
-
- A>sd *.asm/b-
-
- Display all files having an extension of "asm" in the current directory
- of drive A and sort the output by descending file size.
-
- D>sd/v/n/1/r
-
- Display volume label information and all files in the current directory
- of drive D, do not sort the file entries, use one output column, do not
- pause when the console screen fills, and allow output redirection. This
- combination of switches causes SD to behave similarly to DIR.
-
- B>sd \/s/n/2
-
- Select all files in the root directory of drive B, including those with
- the hidden and/or system attribute, do not sort the file entries, and
- display the output using the two column format.
-
- B>sd/r temp.* >c:temp.dir
-
- Select all files having a name of "temp" in the current directory of
- drive B, and redirect the console output to file "c:temp.dir".
-
- B>sd/r/1 c:\*.com >>c:temp.dir
-
- Select all files with an extension of "com" in the root directory of
- drive C, format using one output column, and redirect the console
- output, appending to the file "c:temp.dir".
-
- D>sd a:/v/p/1
-
- Display volume label information, disk parameter information, and all
- file information for the current directory of drive A.
-
- B>sd e:/m/k
-
- Display DOS system version and memory information and the current
- directory of drive E, rounding the space values to kbytes.
-
- C>sd /h/2
-
- Display all files and directories in the current directory on drive C
- sorted and displayed from left to right, using the two column format.
-
- C>sd \/i
-
- Display system information for the disk in drive C and its root
- directory.
-
- A>sd t/c/k/q
-
- Select all files in the current directory of drive A whose names begin
- with "t", clear the screen before displaying output, display file size
- and disk space values in kilobytes and do not pause the console output.
-
- C>sd \/e
-
- Display all files in the root directory of drive C sorted by file
- extension and by file name.
-
- B>sd temp
-
- If temp is an existing subdirectory in the current directory of drive B,
- then select all of the files in that directory. Otherwise, select all
- files in the current directory of drive B whose names begin with "temp".
-
- B>sd temp*.*
-
- Display all directories and files in the current directory of drive B
- whose names begin with "temp".
-
- A>sd ../sar
-
- Display all files in the parent directory of the current directory of
- drive A with either the archive or read/only attribute.
-
- A>sd c:/d/2/@+30
-
- Display all files in the current directory of drive C which were created
- during the past month sorted by date and time, using two output columns.
-
- C>sd \/m/v/p/s/g/1
-
- Display system version and memory information, disk volume information,
- disk parameter information, and all information for all files in all
- directories of drive C.
-
- C>sd \/g/t
-
- Display totals information only for all directories on drive C.
-
- C>sd d:\test/g
-
- Display information for files and directories at and below the "test"
- directory level of drive D.
-
- A>sd c:\*.exe/g
-
- Display information for all .exe files in all directories on drive C.
-
- A>sd c:\/g/sd
-
- Display all directory names on drive C.
-
- B>sd ..\*.a?m/d+/4
-
- Display all files in the parent directory of the current directory of
- drive B whose extensions begin with "a" and end with "m" and sort the
- output by ascending date and time using the four column output format.
-
- C>sd/r/v/1 b:\dir1\dir2\dir3\*.doc/d >prn
-
- Select all files having an extension of "doc" in the directory
- "\dir1\dir2\dir3" of drive B. Sort the output by date and time. Use
- the one column output format and include volume label information.
- Redirect the console output to the printer.
-
- A>sd b:/r (Type Control-P/RETURN)
- (console output is duplicated on the printer)
- A> (Type Control-P/RETURN for PC's, Control-N/RETURN for Z-100)
-
- Display the current directory of drive B and duplicate the console
- output on the printer.
-
- ------------------------------------------------------------------------
-
- Modification History
-
- ------------------------------------------------------------------------
-
- 01-Feb-87 ... V5.4 (Major Rewrite)
-
- Created generic MS-DOS version of program.
- Corrected intermittent looping condition on 80286's.
- Added /? switch to directly display help information.
- Allow help information to be bypassed, if bad switch.
- Terminate program if either ESCAPE or CTRL-C is typed.
- Changed exit from INT 20H to INT 21H function 4CH and
- added return codes for ERRORLEVEL testing by .BAT files.
- Changed 'No files found' message to 'No matching files'.
- Always output values in kbytes if /k switch specified.
- Always display fully qualified path name on totals line.
- Changed /r console output function from OUTCHR to DCIO
- for better performance and to prevent Control-C aborts.
- Added /h switch for horizontal column sorting.
- Added /l switch for output of file names only.
- Added /i switch which is equivalent to /m/v/p/s/t.
- Added /sf switch to select file entries only (no dirs).
- Added /@ switch for file selection before, on, after date.
- Changed /a switch to sort by file allocation unit.
- Added +/- to switches to specify ascending/descending sort.
- Changed /p display from Bytes/Cluster to Sectors/Cluster.
- Identify 16 bit FATs with the notation (16) after Clusters.
- Display starting cluster number of files if /1 specified.
- Read boot sector and display BPB information for /p or /i.
- If /1/p specified, display file starting sector numbers.
- Added support for EGA cards with more than 25 lines.
- Added /25 and /43 switches to switch EGA video modes.
- Added /g switch for global subdirectory processing.
-
- 14-Oct-86 ... V5.3
-
- Display message if no matching files found.
- Added DOS version number to /m switch output.
- Added user patchable foreground and background colors.
- Save registers across call to Z-100 MTR-100 ROM BIOS
- console output routine - fixes system hangs with ROM V2.5.
-
- 26-May-86 ... V5.2
-
- Moved day, date and time to volume information line.
- Added total disk space used to last totals line.
- Added percent of total disk space used to totals line.
-
- 17-May-86 ... V5.1
-
- Fixed parsing bug: sd filename/s -> Bad filespec.
- Display directory entries in reverse video if no /r.
- Added /m switch to display system memory utilization.
- Added /p switch to display disk parms (instead of /v/t).
-
- 12-Feb-86 ... V5.0 (Major Rewrite)
-
- Added /1/2/4/6 output column switches and removed /l switch.
- Changed default output format from 2 to 4 column display.
- Added display of seconds to time information for files.
- Added directory path display to output information.
- Added number of directories and file types to output.
- Added total disk space to output information.
- Added /f sort by filename switch (default sort type).
- Changed /e switch to sort by both file extension and name.
- Added patch area to allow switch defaults to be changed.
- Changed parsing to allow switches before and after filespec.
- Fixed several miscellaneous path/filespec parsing bugs.
- Changed path detection from CHMOD to CHDIR system call.
- Added graphics vertical bar character for IBM-PC.
- Suppressed display of . and .. subdirectories.
- Changed display to 25 output lines for IBM-PC.
- Suppressed trailing delimiter if only one output line.
- Added bad filespec message instead of syntax message.
- Added /k switch to display disk space in rounded kbytes.
- Expanded /s switch with d,a,h,r,s file selection values.
- Added display of disk parameters if both /v and /t specified.
- Removed support for operation under MS-DOS V1.
-
- ------------------------------------------------------------------------
-
- Miscellaneous Information
-
- ------------------------------------------------------------------------
-
- Possible Future Modifications
-
- Option to read FAT to display file clusters & bad sectors.
- Write directly to Video RAM for faster screen output.
- Support full screen operation - forward/backward scrolling.
- Allow options to be changed dynamically & program cloned or
- implement a separate configuration program to clone program.
- Modify to terminate and stay resident.
- Add file management capabilities.
-
- Distribution Policy
-
- The SD54.ARC file may be freely copied and distributed as long as the
- only charge is for media and reproduction costs, etc. Under no
- conditions should the program either be sold for a profit or distributed
- in modified form without the permission of the author.
-
- If you would like to receive the latest version of the program on disk,
- including the 8088 assembly language source code and several other handy
- utilities, send a check to the author at the address below for $20.00.
-
- If you wish to contact me with bug reports, suggestions for
- improvements, and/or especially large financial donations, I can be
- reached using the information provided below:
-
- John F. Stetson
- 42 Tivoli Lake Court
- Silver Spring, Md. 20906
-
- (Home) (301) 946-5615 (after 7 PM)
- (Work) (301) 340-4544
-
- Compuserve [70320,353]
- ------------------------------------------------------------------------