Todd's Directory Sorter v1.3

Disclaimer - I disclaim responsibility for the use or misuse of this product.

NEW

The changes in this release are predominantly due to user response. I thank
those who took the time to send me their suggestions.

The biggest change is support for 12 bit file allocation tables making TDS
usable on floppy disks and ram drives.

I added support for errorlevels in batch mode. TDS returns 0 on successful
operation and 1 if it fails.

I fixed a bug which caused the display to go screwy if you placed the cursor
on the last file and then compress the directory in interactive mode.

I added support for specifying a directory on the command line rather than
just using the current directory.

I added the ability to sort based on the directory bit.

I improved the directory entry editor so that date and time editing is easier.

Suggestions that I did not implement include:

I did not make commands case-insensitive. This is very intentional. Since TDS
has the power to wreak havoc, I wanted to make it difficult to accidentally
make changes to the disk. That is why the user has to press 'G' to sort a
directory and 'W' to write the changes to disk in interactive mode.

I did not alter the TDS display to include all directory entry attributes.
I felt it made the display too cluttered.


WHO

Todd Sankey
sankey@physics.ubc.ca  or   jtsankey@unixg.ubc.ca

Please let me know if you use TDS. Good or bad, I would like your comments.


WHAT

TDS is a utility for managing directories either on the command line or
interactively. The two modes of operation are similar but there are some
features that are slightly different in each.

On the command line the user can sort by name, extension, date, time,
size and/or the directory bit in ascending or descending order. The program
can also recurse through subdirectories. It can compress subdirectories by
removing entries for deleted files and freeing unused directory clusters.
In command-line mode TDS can also check the logical structure of the
disk.

Interactively the user can sort directories by these same keys or using
a custom arrangement. The user can also compress directories by removing
entries for deleted files and freeing up no longer used clusters. In
interactive mode, TDS also allows the user to edit individual directory
entries including name, extension, attributes, date, time, cluster chain,
and size. Interactive mode can also be used to inspect the file allocation
table directly.

WHY

I like to have my directories sorted. That is, the actual directory is sorted
not just the display. I guess I am kind of anal that way.

I wrote TDS for my own personal use but I thought others might
also gain some benefit from it. Consequently, I grant anyone the
right to use it however I remain its owner (ie. it is freeware).


HOW

TDS can be run either from the command line or interactively.

To use it from the command line, type:

tds <sort flags> [/s] [/c] [/v] [/f] [/l[n]] [/d][subdirectory]

  where <sort flags> can be any combination of:
    n or N for sorting by Name in ascending/descending order
    e or E for sorting by Extension
    s or S for sorting by Size
    d or D for sorting by Date
    t or T for sorting by Time
    u or U for sorting by sUbdirectory bit

  and

    /s causes tds to recurse through subdirectories

    /c causes tds to compress subdirectories by removing deleted entries
       and, if possible, freeing unused clusters

    /v causes tds to verify all disk writes by re-reading the sectors
       and checking the results - of course this slows operations
       considerably, especially combined with /s

    /f runs the TDS FAT inspector

    /l checks the logical structure of the disk, the optional [n] parameter
       sets the verbosity level (0, 1, or 2 - default is 1)

    /d runs tds on a specific directory (as opposed to the current directory).
       Note that the /d before the directory name is actually optional provided
       that TDS can positively identify the name as a subdirectory and not
       a list of sort flags. This means that you actually only NEED the /d
       before the directory name if, for example, the directory your specifying
       is NESDUT or something like that.

Sorting is done in the order the flags appear so, for example:
 tds ne will sort first by name and then files of the same name will be
        sorted by extension

Obviously some sort combinations make no sense, such as tds -nes.
The size sort flag is useless since there can not be multiple files
with the same name and extension but different size. TDS does not stop
the user from entering redundant or useless sort combinations, however
they have no effect on the outcome.

In this mode, read-only files and the . and .. directories are NOT sorted.

The disk checking capabilities available with the /l option are as follows.
TDS first compares the two copies of the FAT and reports any discrepancies.
It then checks every directory and file on the disk looking for cross-links
and file sizes which do not match the length of the cluster chain. Finally
it searches for orphaned clusters or FAT entries which are invalid.
Using this option forces the /s switch. It also automatically starts from
the root directory.

To use TDS interactively, just type tds. A full screen display
will appear with all of the files in the directory listed and a status bar
displayed on the bottom line of the display. A cursor is placed on the
first file name. The display works in both 25 and 43/50 line modes. If all
files do not fit on the display, then scrolling right or down will 
bring the remaining files into view.

The files are listed in the order they appear in the directory. Also
displayed are the entries for any deleted files (file name starts with a '').
Files are displayed with the name in lower case type, and directories are
displayed in upper case. If the entry has any of the read-only, hidden,
system or volume flags set, these are displayed beside the entry.

The F1 key can be pressed at any time for context-sensitive help.

The status line displays the current directory name, the current list of
sort flags, the directory status, and the cursor status.

The sort flags are identical to the command line version and can be toggled
on or off by pressing the appropriate key. Actual sorting does not occur
until 'G' is typed. Directory compression can be performed by pressing the
'C' key.

The directory status is indicated by an asterisk ("*") in the status line.
If the directory has been altered, the asterisk is displayed. If present,
the display does not correspond to the information on the disk.

The cursor status is either 'Scrolling' or 'Moving'. When the cursor
is in 'Scrolling' mode, the arrow keys and HOME and END move the cursor
from file to file. In 'Moving' mode, the highlighted file(s) move with the
cursor to allow custom sorting. The cursor is toggled between 'Scrolling'
mode and 'Moving' mode by pressing the space bar or the Enter key. Moving
mode can be extended to move a group of files by pressing the '\' key. This
key has the effect of extending the cursor to include another file in the
group.

The interactive mode keys are:

   SPACE or ENTER - switch between 'Moving' and 'Scrolling' modes
         \        - specify a group of files when in 'Moving' mode
         G        - sort directory according to displayed flags
         n/N      - toggle name sort flag
         e/E      - toggle extension sort flag
         d/D      - toggle date sort flag
         t/T      - toggle time sort flag
         s/S      - toggle size sort flag
         u/U      - toggle subdirectory sort flag
                 - scroll or move cursor up 1
                 - scroll or move cursor down 1
                 - scroll or move cursor right 1 column
                 - scroll or move cursor left 1 column
        ESC       - quit TDS
        F10       - edit the directory entry
	 F1       - pop up a help window

When editting the directory entry, the display shows a window with
the file name, extension, flags, date, time, size and starting cluster.
Use the up and down arrow keys to highlight the desired entry, then press
F10. An edit window for the appropriate entry will appear. Make any changes
and press ESC to abandon them or Enter to accept them.

Note editing the starting cluster pops up another list that is the cluster
chain for the given file. EDITING THIS MAY HAVE VERY SERIOUS CONSEQUENCES!!!
You have been warned. It is edited in the same way a directory is. Move and
select a cluster. Press F10 to edit it. Remember that editing an entry affects
all subsequent entries as the chain now points in a different direction.

The interactive mode FAT inspector is started by entering TDS /f. This
presents a similar display, but the entries are the cluster pointers
contained in the file allocation table.

Quitting interactive mode is done by pressing ESC. If changes have been made,
a window will appear offering to exit without making the changes permanent.
This is your last chance, so be sure you mean it.


CAVEATS

In 'Moving' mode, it is possible to move read-only files and the . and ..
directories. This could have some potentially serious side-effects.
The capability is there if you want it, but be careful because you are
responsible for any consequences.

I have not tried TDS on a DoubleSpace drive but I have tried it on a Stacker
drive. It worked just fine on the Stacker drive, however I caution users because
DOS does not provide any functions for writing directories, so TDS
must read the FAT and the raw sectors associated with a given directory
directly. I do not know how well the two will interact. My recommendation
is that if you want to run TDS on such a drive, run it in interactive mode.
If the display comes up with the correct information, it should run OK since
it will write back to the same place from whence it read.

Since TDS must bypass the DOS directory structure in order to read
and write the directories, care should be taken with its use. I have been
using it for several months now and I have not had a single problem
with it so I am quite confident in it. But I must stress that the
potential for great damage exists whenever a program tries to bypass
the normal operating system controls.

Currently TDS only supports drives which use 512 byte sectors and 12 or 16 bit
FATs. This makes it useful on most hard and floppy drives.

DOS follows certain conventions in its directory entries, such as:
all names are upper case and contain no spaces, and an entry can not be
both a directory and a volume. Despite these standards, TDS will
allow such changes when editing a directory entry. For example, the user
can turn off the directory bit on an entry. The user is responsible for
the consequences.

Editing the FAT is dangerous at best. I have needed the capability at times
so I have included it here.

Since TDS is directly altering directory and FAT sectors, it bypasses
all file sharing controls, so it should not be run with background disk
activity taking place. Probably it should not be run under Windows at all,
or any similar environment.

A similar warning to the previous is that the computer should not be rebooted
or interrupted unless absolutely necessary when TDS is writing to the disk,
especially if it is compressing the FAT. Doing so will almost certainly corrupt
the specific directory and may corrupt the FAT which could make the whole
disk inaccessible.


EXAMPLES

TDS
  - starts TDS in interactive mode

TDS /v
  - starts TDS in interactive mode with write verifying enabled

TDS /c
  - compresses the current directory

TDS /s /c
  - compresses the current directory and all subdirectories

TDS ne /s /c
  - compresses the current directory and all subdirectories
    and sorts them by name and extension in ascending order

TDS /s /c /v
  - compresses the current directory and all subdirectories
    with write verifying enabled

TDS /f
  - starts the TDS FAT inspector in interactive mode

TDS /l0
  - runs the TDS disk checker with minimal display

TDS /l1
  - runs the TDS disk checker with normal display

TDS /l2
  - runs the TDS disk checker with verbose display

TDS us /dc:\work /s
  - sorts the subdirectory c:\work and everything beneath it placing
    subdirectories first followed by files sorted by size

TDS us c:\work /s
  - same as above, the /d is not needed because c:\work can not be mistaken
    for a list of sort flags

HISTORY

TDS 1.3 - Dec. 8, 1994
Added /d option and support for 12-bit FATs making TDS useful on floppies
and ramdrives. Fixed a number of minor bugs.

TDS 1.2 - Apr. 27, 1994
Added /s and /c options. Added ability to edit cluster chain. Added group
move ability in interactive mode. Added FAT inspector and disk checking.

TDS 1.1 - Jan. 16, 1994
Added entry editing and help screens. Fixed bug which occured when a directory
ended on a cluster boundary. Fixed another bug which occasionally caused TDS
to fail with insufficient memory.

TDS 1.0 - Sept. 5, 1993
Initial release.

			Todd.
