The directory structure is like a filing cabinet for your hard disk. It enables you to logically group files with similar functions. When creating your directory structure, a little planning can really pay off in terms of productivity. Think of your filing system. If you threw everything into one drawer, finding a specific document would be difficult. The same problem would occur on your computer if you put all your documents into one directory, or folder.
Consider the logic of the following sample directory structure. In this case, there are separate folders for applications and data. Each application and data folder is further divided into subdirectories to organize data even better.
You can use several commands to manipulate the directory structure.
This table summarizes the most useful commands for directory structure manipulation. The following subsections provide further details of these commands.
Command | Purpose | Syntax |
---|---|---|
DIR | DIRECTORY shows the directory listing, including files and subdirectories of the current directory. | C:\>DIR |
MD | MAKE DIRECTORY creates a new directory or subdirectory. | C:\>MD WORDDOCS |
RD | REMOVE DIRECTORY removes a directory or subdirectory. | C:\>RD WORDDOCS |
CD | CHANGE DIRECTORY traverses the directory structure. | C:\>CD WORDDOCS |
To show a list of all the files and directories on your logical drive, you use the DIR command. This is perhaps the most commonly used DOS command. After you type the DIR command, you see this information about the files and directories that are relative to (in the same folder as) the directory path that you are in:
Directory name or filename and extension
Date and time you created the directory or file
Size of the file in bytes
Total number of files and the space used by the folder as well as the remaining disk space in bytes
Options to use with the DIR command include the following:
DIR /P Pauses between screens-helpful when you have more than one screen of information
DIR /W Shows the list in a wide format
DIR /S Shows all the information within the subdirectories of the directory
Note | The use of a switch, or command option, with the DIR command can be combined with one or more other switches. For example, the command DIR /W /P will show a wide list and will pause if there is more than one page of text to display. |
To define your directory structure, you use commands to create and delete directories. To create a directory, you use the MD, or MAKE DIRECTORY, command. To delete a directory, you use the RD, or REMOVE DIRECTORY, command.
Tip | Before you can remove a directory with the RD command, the directory must be empty of all files and subdirectories. To delete directories that contain files or subdirectories, you should use the DELTREE command. |
Take these steps to practice creating and removing a directory:
From the C:\> prompt in a DOS screen, type MD WORDDOCS and then press Enter.
From the C:\> prompt, type MD SSDATA and then press Enter. This creates the directory named SSDATA.
From the C:\> prompt, type MD TEST and then press Enter. This creates the directory named TEST.
From the C:\> prompt, type DIR and then press Enter. You should see a directory listing that includes the two directories you just created.
From the C:\> prompt, type RD TEST and then press Enter. This removes the directory named TEST.
From the C:\> prompt, type DIR and then press Enter. You should see a list that still includes the directory SSDATA but not the directory TEST.
Tip | At the DOS prompt, you can type /? after any command for additional information and syntax options related to that command. |
You use the CD command to change directories. This command enables you to move fairly easily from one branch of the DOS hierarchical structure to another.
As an example of how to use the CD command, again assume you have the directory structure shown earlier in the section 'Creating a Directory Structure.'
To move down a level-in this case, to the WORDDOCS directory-type this command at the C:\> prompt:
CD WORDDOCS
To move back up one level of the directory structure, use the CD.. command like this:
C:\WORDDOCS>CD..
If you are more than one level down the tree and want to return to the root drive (the C drive), you type CD\ like this:
C:\WORDDOCS\LETTERS>CD\
To test directory manipulation, you will complete the directory structure shown in the preceding section. If you completed 'Test It Out: Using the MD and RD Commands,' skip steps 1 and 2.
If you are not already at the C:\> prompt, type C: at the command prompt and press Enter.
From C:\> type MD WORDDOCS and press Enter. Type MD SSDATA and press Enter.
From C:\> type MD DOS and press Enter. Type MD APPS and press Enter.
Change to the WORDDOCS directory by typing CD WORDDOCS and then press Enter.
From C:\>WORDDOCS> type MD INVOICES and press Enter. Type MD LETTERS and press Enter.
To return to the root level of C:\, from C:\>WORDDOCS> type CD\ and press Enter.
Take the steps needed to complete the directory structure shown in the previous section.
|
|