Ms-dos : MicroSoft Disk Operating System a practical demonstration
To be sure you have grasped the Copy command, copy the file FILE1.TXT to a new file called "MYFILE.DAT"
So far you have used the Dir command for seeing all the files in a directory. However, you can specify that you only want files meeting particular criteria listed. The command looks like this:
NOTE: again the words in italics refer to a generic file name, and should NOT be typed in as written. In the case of the DIR command, the file specification (filespec) refers to the files you wish to look at. It can be left blank, in which case a listing of all the files in the current directory will be listed. When you want to look at only some of the files, you can specify this by means of a wildcard character, indicated by an asterisk "*". (see the DOS appendix for more on wildcards). For example, Type:
This should produce a listing of only the files with the extension "TXT", generally considered to indicate a file containing human-readable text. Another example, type:
This will produce a listing of all the files with a name starting with "FILE" followed by an extension ("TXT", "DAT", "WPS", "WKS" etc).
You should also have noticed that the DIR command gives you more information than just what files are in a directory. Take the following example where you might see something like the following:
FILE1 TXT 128 11-30-93 10.23 am
1 File(s) 56923328 Bytes free
This indicates that there is one file in the directory, named "FILE1.TXT". The 128 indicates the number of bytes contained in the files, telling you how large the file is. One byte is roughly equivalent to one character. The remainder of the line gives the date and time the file was created. At the bottom of the directory listing is how much space is left on the whole disk.
NOTE: this is NOT how much empty space you have in your directory! For practical reasons, each user of the network is allowed only a certain amount of disk space so that one person does not take up the entire disk. As a result, you may run out of room in your account even though your directory listing says there are many millions of bytes available.
You've seen some file names in directory listings. In MS-DOS, filenames consist of two parts, the name proper, which can contain up to eight characters, and the extension, which contains up to three characters. These are the first two items on a line in a directory listing. The name distinguishes the file, and the extension tells what kind of file it is. There are several standard extension protocols. For example "TXT" indicates a text file, "DAT" indicates a data file, "WPS" indicates a Works Wordprocessing file, "etc.
Note: that when you write a file name, the name and the extension are joined together with a full-stop "." with no space between. When a file name appears in a directory listing as above, however, the file name and the extension are displayed separately, with no full stop between.
Showing a file on the screen.
Once you know what files you have, you may want to see what is in them. The TYPE command can be used to view a text file on the screen. The TYPE command looks like this:
Where filename is the name of the text file you wish to see. Let's see how it works. Type the following command into the computer:
Some text should appear on the screen in a readable form. Note however that it scrolls by too fast to read. This can be corrected with the MORE command. Type:
TYPE FILE1.TXT |MORE
This has the effect of breaking the text in the file into screen sized pieces, allowing you to read the text conveniently. (The key is
NOTE: the TYPE command only works with text files! Binary files will appear as garbage, and viewing them on the screen can alter the settings on your computer.
As mentioned earlier, related files can be organised in subdirectories. You can create a subdirectory using the "MD" ("Make Directory") command in response to the MS-DOS prompt. The "MD" command looks like:
As before, the words in italics represent a generic directory name and should not be typed in as written. Substitute the name of the new directory to be created. This new directory will appear as a subdirectory in the current directory.
Use the MD command to create a directory called "MYDIR". While still in your home directory, type the following:
Confirm that it has been created by getting a directory listing. You should see the name of the new subdirectory in the directory listing. Notice that after the subdirectory name "MYDIR" a "
As a new directory, MYDIR is empty. To put a file in the directory, type:
COPY FILE1.TXT \MYDIR\FILE1.TXT
Note the use of the path to specify that the destination file is in another directory.
Viewing directory Trees
A useful command that enables you to view the directory tree, is the TREE command. To see your directory tree, type:
You should see a tree diagram of your directories. If you wish to see what files you have in the directories and subdirectories, type;
The "/F" is known as a "switch", and you should get in the habit of placing a space between the command and the switches.
The next step is to make the new subdirectory the current directory. When you log in, you will always be placed in your home directory. This is you current directory when you start. At times you may wish to work in another directory. You can change the current directory by using the "CD" ("change directory") command, which looks like this:
The words in italics represent the name of the directory to be changed to, and should not be typed as written. Type:
Note that the prompt has changed to look like:
The prompt is set up to show you which directory is the current directory. This way you will always know where you are currently in the directory structure. Look at the directory listing. You should see the file you copied into the subdirectory. Now type:
This should show you the listing for the root directory, as you have specified the root with a path. Alternatively, you could use the DOS notation for parent directories. In each listing, at the top you will see a line with a directory named "." and another named "..". This is MS-DOS' way of following the directory structure. The "." refers to the current directory, and ".." to the parent directory. Type:
This should also give the directory listing for the root directory, which is the parent of MYDIR. The . .. notation will work with the other commands. Type:
This will make the parent directory the current directory. Check the prompt and get a directory listing to verify that you are back in your home directory. Then make MYDIR the current directory again.
Renaming a file.
There are times when you want to give a file a new name without changing the contents. For example, a file may have been named incorrectly and the name must be changed to get the computer to do what you want. File names can be changed by means of the REN command, which has the following syntax:
REN oldname newname
The REN command takes an existing file, "oldname", and gives it a new name "newname". Try renaming the file in the MYDIR directory. Type the following:
REN FILE1.TXT JUNK.TXT
This will rename the file FILE1.TXT to JUNK.TXT. Get a directory listing to confirm this has worked. At some point you may forget the proper way to use the REN command and only give it one file name. No worries; you will simply get an error message like this:
Required parameter missing
No harm will be done to the system or your files. Try typing
You should see the error message. It should also show that making mistakes on a computer is not disastrous (usually).
Deleting a file.
As you continue to use the computer, you will accumulate files which are no longer needed. To save space on the disk, it's a good idea to delete files you don't need any more, and you should try to make cleaning out redundant files a regular habit. This is done with the DEL command.
This removes the file from the directory listing. Be careful! Once you delete a file there is no easy way to get it back. The information it contains will be lost, so use this command with care.
This will delete the file OLDFILE.TXT.
The first example will delete all the files with the extension OLD, regardless of the file name. The second will delete all files with the name OLDFILE, regardless of the extension.
This command will delete all the files in your current directory. Because this could be disastrous, it will first ask you
Are you sure (Y/N)?
If you type N, it will stop without deleting anything. If you type Y it will go ahead and delete all the files in the directory. Be careful with this one, because you cannot retrieve deleted files.
Try the DEL command. First do a DIR command to view the files currently in the MYDIR directory. Then type:
Now do a DIR command. If all went well, the file JUNK.TXT should no longer be in the directory.
Change the current directory back to the root. The command to remove a directory is:
Where RD stands for `Remove Directory', and dirname is the name of the directory to be deleted. It is important that the directory to be deleted is empty. MS-DOS will prevent you from deleting any directory which contains files. Make sure that the MYDIR subdirectory is in fact empty. Then type:
Get a directory listing to confirm that the directory has been deleted.
Printing a file.
When you want to obtain a printout of a file (known as hard copy, as opposed to soft copy, which refers to files on a disk), you can use the PRINT command. This has the following syntax:
As before, the word in italics refer to a generic file name and should not be typed in as written. To obtain a hard copy of the file FILE.TXT, type the following command:
This will send a copy of the file to the printer. It may take a few minutes for the file to be printed, especially if many people are using the printer, so please be patient.
3. Disk Drives
Most of today's computers can be set up with more than one disk drive. The PCs in the laboratory do not use internal drives. Through the network they use several hard drives which are attached to the server. In MS-DOS, disk drives are identified by letter names. Take another look at the prompt.
In this instance, the "H:" on the left side of the prompt is the name of the default drive. The operating system will look for files on this drive first.
Default drives. You can change the default drive to another by typing the name of the new drive followed by a colon. To change the default drive, type:
Notice that the prompt has now changed to J:\> The default drive is now the J: drive. To change back to the H: drive, type.
Notice that the prompt has changed back to what is was before,
You can change the default directory on another drive. While still in your home directory on the H: drive, type:
Notice that you are still in the same directory on the same drive. But when you switch to the J: drive, you will automatically be in J:\SF100, the new default directory for that drive. Try this and examine the new default directory name.
Use the commands you have examined for changing between disks and directories, and for listing directory contents, to explore the directory structure on the J: drive.
4. Miscellaneous Commands.
To finish, here are a few commands which may be of use. First, make sure you are in your own root directory (H:\).
a) To find the current data or time, MS-DOS provides the DATE and TIME commands. Type
You should see a message like:
Current date is "Current date"
Enter new date (mm-dd-yy):_
If the current data displayed is wrong, correct it by typing the data in the format specified (month-day-year). Otherwise press . The TIME command works in a similar manner. Try it out.
b) Clearing the screen. Sometimes you may find your screen covered in garbage, or too crowded to comprehend in a straightforward way. To clear the screen, MS-DOS provides the CLS command. Type:
The screen should now be blank, except for the prompt in the top left-hand corner.
c) Setting the prompt. MS-DOS allows you to change the prompt to suit your own preferences. The prompt command looks like
PROMPT $character $character
Where $character can be any of the following:
$d The current date
$t The current time
$p The current directory
$g The > character
$l The < character
$q The = character
$b The Ý character
$$ The $ character
$h Backspace (erases a character written to the prompt)
The current prompt is set to $p$g. Try typing:
Now you should see the prompt as ">>". You can add things like the time to the prompt. This is handy as it will generally be right in front of you. Type
You will see that this gives the time far more precisely than most people will require. You can trim the value given by erasing some of the characters to the right, using backspace. Type
This should be a little easier to understand at a glance. Consider what his prompt command does:
PROMPT $d$h$h$h$h$h$h$h$h$h$h$t$h$h$h$h$h$h $p$g
Try a few of the combinations and see what happens. If you intend regularly using a different prompt, remember to include $p, so that you know at a glance what your current directory is.
[M H Verhaart]
Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016