Directories are simulated file folders on a disk. To understand directory basics, look up DOS abc's.
Directories and Subdirectories
DOS directories are hierarchical in structure. The starting point is the root directory. In fact, when several people use the same computer, the "directory tree" looks like an organization chart:
A subdirectory is a directory that is subordinate to (below, or attached to) another directory like BUDGET and TEXT above. Since all directories are below the root directory, all directories are technically subdirectories. The two terms become intertwined. Don't worry about this.
More importantly, don't set up too many levels in the hierarchy or you'll drive yourself nuts trying to manage them at the DOS prompt. However, if you have a menu system that let's you point to the directory you want, you can manage several levels of directories more easily.
A Real Bummer
The hardest thing about DOS commands is creating the proper path name to the files you want to work with.
It's tricky because the structure for naming the path isn't clearcut. The culprit is the backslash symbol (\), which means two entirely different things depending on its position in the path.
The first time it's used, it stands for root directory. The second and subsequent times it's used, it's a symbol that separates file and directory names.
The following commands for creating, removing and changing directories will show you many ways path names are used. There are plenty of examples that follow:
Creating a Stand-Alone Directory
A stand-alone directory is one attached to the root. To create stand-alone directory KAREN, type:
C:\ANYWHERE>cd \ go to the root C:\>md karen make directory off the root C:\> you're still in the root
To go to that directory, type:
C:\>cd karen change directories C:\KAREN> prompt changed to Karen
Note!
Directories are named the same as files, with a name up to eight characters and an optional extension of up to three. See DOS file names.
Creating a Subdirectory
To create a subdirectory called BUDGET that is located within the KAREN directory, type:
* C:\ANYWHERE>cd \karen go to KAREN
C:\KAREN>md budget make subdirectory
** C:\KAREN>cd budget go to budget
C:\KAREN\BUDGET> prompt has changed
* Going to KAREN requires a backslash in front of KAREN, because the first backslash means ROOT directory, and KAREN is off the root.
** Going to BUDGET does not use the backslash, because BUDGET is off KAREN, not off the root. More on this in a moment.
Also Note!
The above methods were chosen for demonstration, because the syntax is the same for creating both stand-alone directories and subdirectories. However, you should know that you can create both types of directories no matter which directory you're in. For example, from the ANYWHERE directory, you could have created KAREN by typing md \karen being sure you have the backslash in front of KAREN. You could then attach the BUDGET subdirectory to KAREN with md \karen\budget.
Removing a Directory
First, be sure all files in the directory have been erased. Second, move back a level to the directory before it.
The following example switches to the KAREN directory, deletes all files, moves back one level and removes the KAREN directory:
C:\>cd karen go to KAREN
C:\KAREN>del *.* delete all files
C:\KAREN>cd .. move back one level
C:\>rd karen remove KAREN directory
Remember!
1. You cannot be in the directory you're deleting.
Go to the level before it.
2. If you're using DOS 5 or an earlier version, you
cannot delete a directory that is not empty. In
DOS 6, you can with the use of the Deltree
command.
Switching Directories
The CD (change directory) command means go to another directory. What actually changes is the DOS prompt, which displays the name of the directory you've switched to.
Suppose you have three subdirectories under the PLANS directory:
C:\PLANS\1991
C:\PLANS\1992
C:\PLANS\1993
If you're in the 1991 directory and you want to go to the 1992 directory, you have to state the path starting at the root:
C:\PLANS\1991>cd \plans\1992
C:\PLANS\1992>
Another way is to type:
C:\PLANS\1991>cd .. back up one level
** C:\PLANS>cd 1992 go to 1992
C:\PLANS\1992>
**Note: When going from PLANS to 1992, you don't use the backslash (\), because 1992 is subordinate to PLANS, not the root.
Let's examine this some more. In the command:
cd \plans\1991
The first \ means ROOT. The second \ separates one directory name from another. Therefore, if you're in PLANS already, you cannot type:
C:\PLANS>cd \1991
You'll get an "Invalid directory" message, because 1991 is not off the root.
\1991 means root 1991
Using the PLANS directories again:
C:\PLANS\1991
C:\PLANS\1992
C:\PLANS\1993
Only the first example below is correct:
correct C:\PLANS>cd 1991 1991 is off PLANS no good C:\>cd 1991 You're in the root no good C:\>cd \1991 1991 is not off root
Switching Between Drives
When switching between directories on different drives, you must switch drives first.
For example, to switch from C:\PLANS\1991> to D:\BUDGETS>, you would type:
C:\PLANS\1991>d: switch drives first
D:\>cd budgets then change directories
D:\BUDGETS> prompt has changed
Think of drives as buildings and directories as floors. You cannot get to the 3rd floor of the college if you're on the 2nd floor of the high school by simply switching floors. You have to leave the college and go to the high school first.
Using Paths with Other Commands
Drive letters ARE NOT used with the CD command.
Drive letters ARE used with all other commands whenever the drives are not implicit. For example, to copy the SALES worksheet from C:\PLANS to D:\BUDGETS, you would type:
E:\ANYWHERE>copy c:\plans\sales.wk1 d:\budgets
In the above example, notice that, because you're in drive E, both FROM and TO drive letters must be used (C: and D:).
Also notice that the SALES file name is simply added to the end of the path, separated by a backslash.
If you were already in C:\PLANS, you would only need to reference the file name:
C:\PLANS>copy sales.wk1 d:\budgets
Download Computer Desktop Encyclopedia to your iPhone/iTouch




