Classic Computer Magazine Archive COMPUTE! ISSUE 123 / NOVEMBER 1990 / PAGE 20



A subdirectory system for disk files works much the way closets and dressers work for storing clothes. Subdirectories are essential on hard drives and can be quite useful on floppy drive systems. Floppy drive systems are usually organized by disk: one disk for word processing, one for spreadsheets, and one for databases. When you move to a hard disk, don't destroy your organization by plopping everything in the root directory. Create a subdirectory system that mirrors your floppy disk system.

The root directory is the foundation for all other directories. It is signified by the drive name and a backslash, as in C: \. It's common to store many files in the root directory because it's convenient, but efficiently organized disks will have few files in the root directory. The root directory is a place to organize your other directories. A clean root directory has only the system startup files and the names of other directories.

Many root directories are filled with .BAT files, most left behind by commercial software installation programs. Let's create a subdirectory for those batch files and move all of them, except AUTOEXEC.BAT, into the new directory. Use the MKDIR (or MD) command to create the directory. Type MKDIR \ BATCH and press Enter.

Now, copy all the batch files to the new directory. You could copy each individually, but it would be quicker to copy them en masse with the command COPY *.BAT \ BATCH. Before you execute the command, though, recall that AUTOEXEC.BAT shouldn't be moved. To keep it out of harm's way, temporarily rename AUTOEXEC.BAT to something like AUTOEXEC.SAV.

Now, COPY *.BAT \ BATCH copies all remaining batch files to the new directory. Get a listing of the new subdirectory (DIR \ BATCH) to make sure all files were copied safely; then erase all the batch files in the root directory with the command ERASE \*.BAT. Finally, use RENAME to restore AUTOEXEC.SAV to AUTOEXEC.BAT

Everything is back to normal except that the system can't locate the moved batch files. You'll have to modify your PATH, which tells DOS where to look if it can't find files in the current subdirectory.

To see the current path, type PATH and press Enter. If a path exists, it was probably entered during the execution ofAUTOEXEC.BAT upon boot up. The easiest way to update the path is to modify the command in AUTOEXEC.BAT. Using a text editor, call up AUTOEXEC.BAT and add the new subdirectory to the existing path. If you have a hard disk named drive C, the entry C: \ BATCH; would be added to the end of the current PATH = line in AUTOEXEC.BAT. Now, reboot the system and you can execute any of the batch files in the BATCH subdirectory.

Navigating subdirectories is confusing for many computer users. The key is to know where you are in the directory tree. The root directory (signified by the drive name and the backslash) is the trunk of the tree. The subdirectories are branches that deviate from the root directory.

Assume a directory structure that looks like this:

The CHDIR (or CD) command is used to change directories. Enter CD WRITING and the WRITING subdirectory becomes the system default. That's simple enough, but how do you change to another subdirectory or find a file without getting a Path not found message?

The trick is to remember where you are on the directory tree and to remember that you are human, not a squirrel. A squirrel makes a flying leap from one branch to another; a prudent human climbs down to the trunk and then climbs out on another limb.

WRITING and GAMES are branches of the root directory. To get from WRITING to GAMES, you must climb down to the ROOT and then back out to GAMES. Do this with the command CD \ GAMES. Note the backslash, and remember that it signifies the ROOT directory.

If you had entered CD GAMES (without the backslash), the system would have looked for GAMES as a subdirectory of WRITING. Finding none, it would have responded Path not found.

Now, assume you want to move from GAMES to PUZZLES. Type CD PUZZLES. Because you're moving farther out on the same branch, there's no need to go back down to the ROOT by using a backslash. If you had used the command CD \ PUZZLES, the system would have looked for a subdirectory called PUZZLES directly below the ROOT directory.

Draw yourself a picture of your system's directory tree. Once you have a clear idea of what it looks like, you can climb about without getting lost.