Friday, October 5, 2007

MD,RD and CD commands

In DOS you can create additional directories on a disk. These directories are known as “Subdirectories”. The directory that contains them is known as the “parent” directory. The directory that is created at the time the disk is formatted is called the “root” directory and is denoted by the backslash “\”. There are 3 commands for dealing with directories (folders) in DOS: the MD, RD and CD commands. MD (or MKDIR) allows you to create a new subdirectory and you type this preceding the file name you will name it for example if you want to make a subdirectory called “abc” you will type in md abc. To make a folder inside another folder you need to type first the location of where the main folder you want to store this subfolder so for example if you want to save “main” folder inside folder abc it would read as follows : md [d:]\ abc\main. Once again the [d:] stands for the certain drive that the folder abc was stored in. TO make a directory in another drive although you are in a different drive you type in md [d:] and specify that other drive toy want your new folder to be in. RD (or RMDIR) allows you to remove a directory but you can only remove a directory if it’s empty. When removing for example “abc” you type in rd abc. You always need a verb (remove) and an object to remove (ex: abc) to use this command.
The CD (or CHDIR) command signals changing from one directory location to another as you jump from one branch of the tree to another. To move from any directory to the root of the current drive you type in cd\. The backslash “\” refers to the root. For example if you type in cd\word the first “\” refers to the root and this command is telling you to find this word folder in the root directory. There’s another notion in DOS of dot “.” and dot dot“..”. In order to move from any directory to its immediate parent directory you type in “cd..” since 2 dots refer to the parent which is listed above the directory you are in. If you type in one dot after cd like this “cd.” Just leaves you in the current directory that you are in. If you type in “cd” by itself it will cause DOS to output a “fully qualified path” for the current directory. A fully qualified path is a listing of all the directories starting with the drive letter followed by “\” for example “C:\” on the path down the branches up to and including the current one. In the same folder you can only have one file with the same name, but outside that folder you can have the same name in another folder. If you want to see the fully qualified path of C:\> DIR docs\abc.doc DOS is looking for the “docs” folder in wherever directory you are in and it’s also looking for the abc.doc file name inside this docs folder once it’s found.

No comments: