|
The DOS directory structure can be thought of as a tree, with the master disk directory being called the root and subdirectories thought of as branches. The root is the hard disk's master directory. It may contain up to 512 entries. Subdirectories may contain any number of entries (until the disk is full). A floppy root directory may contain 112 or 224 entries. A typical tree might look like...
In the example there are five files and two subdirectories in the root. Each of the subdirectories has similar contents. SubDir1, for example, has three files and one subdirectory in it. This structure can be extended until the disk is completely full, subject only to the constraint of 63 characters for the pathname that you will use to find a particular file. The rules for a subdirectory name are just like that for filenames (eight characters followed by a period and three character extension). They show up in a directory listing with the designator <DIR> behind them. Let's see now how to build a pathname. PathnamesAssume the subdirectory structure (only directories are shown, not files)...
This series of subdirectories was set up to categorize various files developed by a word processor. Let's move in the structure:
Note that each subdirectory in the path is separated by a backslash (\). The single backslash at the beginning of the pathname indicates the root. All pathnames must originate in either the current directory or root. A test -- What is the pathname from the root to the subdirectories listed below?
Answers...
When DOS is booted, the root directory is automatically selected. To type a file named MYMEMO.TXT in subdirectory MEMOS the command would be:
\WORDPROC\MEMOS\ is the pathname that DOS would use to find the file MYMEMO.TXT and then show it on the screen. If you've got work to do with files in the MEMOS subdirectory, typing the complete pathname all the time would be inefficient. Therefore, DOS gives you a method of making DOS recognize the MEMOS directory as the default: the Change Directory command. To change to the MEMOS subdirectory from the root the command would be:
If set properly (see just below) the prompt might also change to reflect the change directory (C:\WORDPROC\MEMOS>, and a DIR command would now show the contents of the MEMOS subdirectory instead of the root and DOS would look for all command files in that subdirectory instead of the root. An easy way to keep track of where you are in the directory tree is to use the PROMPT command to set a prompt that shows the current directory along with the current drive. You can easily do this by adding the line:
to your AUTOEXEC.BAT file. Make and Remove SubdirectoriesIf you are going to have subdirectories, there must be a way to make them. The syntax for the make directory command is:
You can make a subdirectory IN any directory FROM any directory so long as you give the appropriate pathname. Usually, you will change to the directory you want the subdirectory to be in and then issue a simple MD DIRNAME command. That way there is no mistake about what will happen. When you no longer need a directory you may remove it from the disk. The first thing you have to do is empty it of files and move out of it. Only then will you be able to remove it. The syntax for removing is:
You cannot remove the root directory (it's the master for the disk and when it's the only directory you would have to be in it, and you can't remove a directory you are in). Note: In DOS 6.0 the command DELTREE was introduced. DELTREE will both remove files from a directory and remove that directory with a single command. Mysterious DotsWhen you are in a subdirectory and issue the DIR command, you will see something like this:
The dots indicate you are in a subdirectory. The single dot is the current directory and the double dots are the parent to the current directory. Thus you could move to the parent of TUTORIAL (in the example above) by simply issuing the command CD .. Used with care, the dots can speed up subdirectory commands. TreeAll directory paths and their relationships are called a tree. If you don't remember the various subdirectories (and optionally the files in them) DOS offers you a chance to see them with the TREE command:
This command lists all paths from the root on the disk. If you use the /f option, you will also see all files in each subdirectory. (Only the filenames are shown, not their size or creation date/time.) For a permanent record, press Control-PrtScr before issuing the TREE command and again after. Your printer will record all text scrolling past on the screen. (Or redirect to a file with TREE d:/f > Filename.) [Note: TREE has been removed under Windows.] Subdirectory ReviewAssume the shown subdirectory structure...
The following series of commands perform the indicated functions. Study them and make certain you understand them. From the root:
To move from the root to the subdirectory MEMOS type:
Remember, to make any directory the current directory, simply issue the CD command using the pathname that you would use to access any file in that subdirectory. CD \ alone will move you back to the root from anywhere. From the root, the following command removes the subdirectory LETTERS:
Remember, before you can remove a subdirectory, it must be empty (all files deleted and other subdirectories removed), you cannot be in it, and you cannot remove the root directory. In DOS 6.0 you can do both with the single command DELTREE. A final reminder: Use subdirectories as needed, but don't overdo it. Pathnames are limited to 63 characters; and, you can get lost in the directory structure if you create a very complex one. PROMPT $P$G will help you keep track. Also, directories are not free. Each takes up some disk space so if you fill your disk with directories, there won't be room for anything else. |
Please use the contact
form for questions or comments about this web site.
Copyright © 2001
Computer Knowledge, All Rights Reserved
Pray the Rosary for peace.