Documente Academic
Documente Profesional
Documente Cultură
This tutorial gives you an opportunity to try basic MS-DOS commands. By following the
procedures in this section, you will learn to:
○ View the contents of a directory
○ Change from one directory to another
○ Create and delete directories
○ Change from one drive to another
○ Copy files
○ Rename files
○ Delete files
○ Format a floppy disk
When you typed the second copy command, you specified the source filename as EDIT.HLP instead of
C:\DOS\EDIT.HLP. This is because drive C is the current drive, so you did not have to repeat C: in the path. The
DOS directory is the current directory, so you did not have to repeat DOS in the path. You had to specify only the
filename.
For the destination directory, you specified the relative path as FRUIT instead of C:\FRUIT. Again, you did not need
to specify drive C, because drive C is current. However, the FRUIT directory is not current. To access the FRUIT
directory from the current directory, DOS, MS-DOS must first return to the root directory (), and then switch to the
FRUIT directory, before copying the file to its new location. Therefore, you typed the path MS-DOS must take to
switch between the current directory and the FRUIT directory, or \FRUIT.
Copying a Group of Files
In this section, you will use wildcards to copy a group of files from the DOS directory to the FRUIT directory. In a
card game, a wildcard matches any card in the deck. In MS-DOS, the asterisk (*) wildcard matches any character in
that position and all the other positions that follow it. If you want to copy a group of files with similar names, using
wildcards is easier than copying each file individually.
In this section, you will first view a group of files by using wildcards, and then copy the files using wildcards.
Before you begin this section, make sure your command prompt looks like the following:
C:\DOS>
To list all files ending with the extension TXT and copy them from the DOS directory to the FRUIT directory by
using wildcards
1. View all the files in the DOS directory that end with the extension TXT by typing the following at the
command prompt:
dir *.txt
Note that there is a space before the asterisk (*), but not after it.
This command directs MS-DOS to list all files and subdirectories in the current directory that end with the
extension JXT. The asterisk matches the first character of the filename and all other characters that follow
it, up to the period () that separates the name from the TXT extension. A list similar to the following
appears:
Volume in drive C is MS-DOS_6
Volume Serial Number is lE49-15E2 Directory of C:\DOS
NETWORKS TXT 8369 11-11-93 5:00a
OS2 TXT 4587 11-11-93 5:00a
README TXT 10858 11-11-93 5:00a
3 file(s) 23814 bytes
MS-DOS lists all the files that end with a TXT extension. The wildcard in your command specified that
MS-DOS should ignore the very different beginnings of the files and focus only on the extensions.
Next, you will copy all the files with a TXT extension to the FRUIT directory by using wildcards.
2. To copy the files with a TXT extension to the FRUIT directory, type the following at the command prompt:
copy *.txt \fruit
This command copies all the files that have the TXT extension from the current directory (DOS) to the
FRUIT directory.
3. To confirm that you copied the files successfully, change to the FRUIT directory by typing the following at
the command prompt:
cd \fruit
4. To view a list of all the files in the FRUIT directory, type the following at the command prompt:
dir
A list similar to the following appears:
Volume in drive C is MS-DOS_6
Volume Serial Number is lE49-15E2 Directory of
C:\FRUIT
. <DIR> 09-27-93 11:11p
.. <DIR> 09-27-93 11:11p
EDIT COM 413 11-11-93 5:00a
EDIT HLP 17898 11-11-93 5:00a
NETWORKS TXT 8369 11-11-93 5:00a
OS2 TXT 4587 11-11-93 5:00a
README TXT 10858 11-11-93 5:00a
7 file(s) 42125 bytes
40652800 bytes free
The EDIT.COM and EDIT.HLP files are the files you copied by following the procedure in the previous section. The
files with TXT extensions are the ones you just copied by using wildcards.
Renaming Files
This section explains how to rename files. You may want to rename a file if the information in it changes or if you
decide you prefer another name.
To rename a file, you will use the ren command. The ren command stands for "rename." When you use the ren
command, you must include two parameters.
The first is the file you want to rename, and the second is the new name for the file. You separate the two names
with a space. The ren command follows this pattern:
ren oldname newname
• Renaming a File
In this section, you will rename the README.TXT file.
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
1. To rename the README.TXT file to PEACH.TXT, type the following at the command prompt:
ren readme.txt peach.txt
2. To confirm that you renamed the file successfully, type the following at the command prompt:
dir
The name PEACH.TXT should appear instead of the name README.TXT. It is the same file, but now has a
different name.
Renaming a Group of Files
You also can use wildcards to rename a group of files. If you want to rename a group of files that have similar
names, using wildcards is easier than renaming the files individually. In this section, you will rename a group of files
by using wildcards.
Before beginning this section, make sure your command prompt looks like the following:
C:\FRUIT>
• To rename the files whose names begin with EDIT by using wildcards
1. List the files in the FRUIT directory that begin with EDIT by typing the following at the command prompt:
dir edit.*
A list of the files in the FRUIT directory that begin with EDIT appears.
2. To rename the files that begin with EDIT to the new name PEAR, type the following command:
ren edit.* pear.*
This command specifies that all the files that begin with EDIT should be renamed PEAR, but should keep
their original extensions.
3. To confirm that you renamed the files successfully, type the following at the command prompt:
dir pear.*
When the files were renamed, their extensions remained the same. For example, EDIT.COM became
PEAR.COM, and EDIT.HLP became PEAR.HLP.
You can also rename extensions this way. For example, suppose you want to indicate that a group of files
ending with a TXT extension are old. You can use wildcards to rename the files so they have the extension
OLD.
• To rename all the files in the current directory whose names end with the extension.TXT
1. View a list of all the files in the current directory with the extension TXT by typing the following
command:
dir *.txt
2. To rename all files in the current directory that end with the extension TXT to end with the extension OLD,
type the following command:
ren *.txt *.old
3. To confirm that you renamed the files successfully, type the following at the command prompt:
dir
The files that had the extension TXT now have the extension OLD.
Deleting Files
This section explains how to delete, or remove, a file that you no longer want on your disk. If you don’t have very
much disk space, deleting files you no longer use is essential.
To delete a file, you will use the del command. The del command stands for "delete."
• Deleting a File
In this section, you will delete two files using the del command.
Before you begin, make sure your command prompt looks like the following:
C:\FRUIT>
To delete the PEARCOM and PEAR.HLP files
1. Delete the PEAR.COM file by typing the following at the command prompt:
del pear.com
2. Delete the PEAR.HLP file by typing the following at the command prompt:
del pear.hlp
3. To confirm that you deleted the files successfully, type the following at the command prompt:
dir
The PEAR.COM and PEAR.HLP files should no longer appear in the list.
• Deleting a Group of Files
In this section, you will use wildcards to delete a group of files.
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
To delete files in the current directory that end with the extension OLD by using wildcards
1. View all files that end with the extension OLD by typing the following at the command prompt:
dir *.old
A list of all the files that end with the extension OLD appears. Make sure that these are the files you want to
delete. When you are deleting files by using wildcards, this step is very important. It will prevent you from
deleting files accidentally.
2. Delete all files ending with OLD by typing the following at the command prompt:
del *.old
3. To confirm that all the files with the extension OLD have been deleted, type the following at the
command prompt:
dir
The FRUIT directory should contain no files.
Now that the FRUIT directory is empty, you can delete it by using the rd (remove directory) command that you
learned to use in "Deleting a Directory" earlier in this chapter.
• To delete the FRUIT directory
1. Return to the root directory by typing the following at the command prompt:
cd \
2. You can see the FRUIT directory in the directory list by typing the following at the command prompt:
dir or dir /p
3. Remove the FRUIT directory by typing the following at the command prompt:
rd fruit
4. To verify that the FRUIT directory has been removed, type the following at the command prompt:
dir or dir /p
The FRUIT directory should not appear in the directory list.
Formatting a Floppy Disk
When you purchase new floppy disks, you may be required to format them before you can use them. Practice
formatting a floppy disk now.
Caution The data on the disk you format will be erased, so make sure you select a disk that does not contain
information you may need later.
• To format a floppy disk
1. Type the following at the command prompt:
format a:
This command specifies that you want to format the disk in drive A. When you press ENTER, the
following message appears:
Insert new diskette for drive A:
and press ENTER when ready ...
2. Insert the disk you want to format in drive A label-side up. Then close the drive door or make sure the disk
clicks into the drive. When you are ready, press ENTER. The following message appears:
Checking existing disk format
Saving UNFORMAT information
As it formats the disk, MS-DOS displays the percentage of the disk that has been formatted. When the
format is complete, the following message appears:
Volume label (11 characters, ENTER for none)?
3. A volume label is a name for your disk. You can give your disk any name you like, as long as it has 11 or
fewer characters. For this exercise, type practice and then press ENTER. Information similar to the
following appears:
1213952 bytes total disk space
1213952 bytes available on disk
512 bytes in each allocation unit.
2371 allocation units available on disk.
Volume Serial Number is lE49-15E2 Format another
(Y/N)?
4. If you have another disk to format, press Y. If not, press N.
Summary
This concludes the MS-DOS tutorial. During this tutorial, you learned how to:
• View the contents of a directory by using the dir command.
• Change directories by using the cd command.
• Create directories by using the md command.
• Delete directories by using the rd command. C
• Change drives by specifying the drive letter followed by a colon.
• Copy files by using the copy command.
• Rename files by using the ren command.
• Delete files by using the del command.
• Format a floppy disk by using the format command.