DOS Directory Commands

DOS uses directories to organize the files on your disks. That means we need to use directory commands to create a structure to store our files, and to find the files we have stored there.
The commands we need are relatively few:
COMMAND | USE FOR |
---|---|
MD (or MKDIR) | Create a new directory or subdirectory |
RD (or RMDIR) | Remove a directory or subdirectory |
CD (or CHDIR) | Change from the current working directory to another directory |
DIR | List the contents of the current working directory |
DELTREE | Erases a directory, including any files or subdirectories it may contain. |
Because working with directories is central to what DOS does, all of these (except DELTREE) are Internal commands, contained within COMMAND.COM, and therefore
loaded into RAM and ready for your use whenever you boot, including from a boot disk.
You will note that the first three commands have two versions, a two-letter shorter name and a longer name. There is no real difference in use, so I will use the short form consistently in the presentation.
MD
This command creates a new directory or subdirectory. (Actually, since the root is the main directory, all directories are subdirectories. So I will refer to subdirectories in all of
the following.) Optional argument is the PATH, but if no PATH is included, the subdirectory will be created in the current working subdirectory
Example:
C:\>md letters
This would create the subdirectory
C:\letters
With a path included, you can create a subdirectory anywhere.
C:\>md c:\letters\love
If you are in a different working subdirectory:
C:\letters\>md love
This would have the same effect as the previous example. Since we were already in the C:\letters subdirectory as our current working subdirectory, we can leave out the path information since this is where we want the subdirectory created.
Limitations: The length of a PATH specification cannot exceed 63 characters, including backslashes.
RD
This command removes a subdirectory. The subdirectory must be empty. If it contains files and/or subdirectories, you will get an error message.
This also has an optional PATH argument, and has the same syntax as MD. Note that you cannot remove the current working subdirectory. To do this, CD to the parent subdirectory first, then remove the undesired subdirectory.
The RD command can sometimes be a little confusing because of the safeguards that DOS builds into the command. The idea that you cannot delete a subdirectory that has contents, for instance, is a safety measure. (DELTREE gets around this, but is a dangerous command for precisely that reason.)
How can you tell if a subdirectory is empty? By using the DIR command to display its contents.
0 comments:
Post a Comment