0% found this document useful (0 votes)
107 views

MS Dos

The document provides instructions on learning basic MS-DOS commands. It discusses: 1) The command prompt and how to navigate directories and drives. 2) Common commands like DIR, COPY, DELETE, FORMAT and their proper usage. 3) Creating, deleting, and managing files and directories through examples.

Uploaded by

tharaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

MS Dos

The document provides instructions on learning basic MS-DOS commands. It discusses: 1) The command prompt and how to navigate directories and drives. 2) Common commands like DIR, COPY, DELETE, FORMAT and their proper usage. 3) Creating, deleting, and managing files and directories through examples.

Uploaded by

tharaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

DCS5058 – OPERATING SYSTEMS MS DOS

PART 1
What You Need to Learn
To get the most out of your MS-DOS system you must learn the following:

 You must learn how to care for your computer hardware. Your computer is a machine.
All machines require routine maintenance to ensure proper operation and a longer life.

Usually instructions on the care of your computer are included in the Operations Guide
which came with your computer.

 You must learn how to use the MS-DOS filing system to organize the information (files)
stored on your computer. This includes the proper use of directories to group related files
together, and to separate non-related files. Properly organizing the files on your system is
necessary if you want to efficiently use your computer.

The MS-DOS filing system is maintained using the directory manipulation commands:
MD (Make Directory), RD (Remove Directory), and CD (Change Directory).

 You must learn how to protect the information stored on your computer. Eventually your
computer will break down. When it does, you will want to easily recover the lost
information from other sources.

The best way to protect yourself is to have more than one copy of all your important files.
Then, when your computer breaks down, you can copy your files onto a new computer
and keep working.

You can use the DISKCOPY command to duplicate entire floppy diskettes, the COPY
command to copy individual files onto other disks, and the BACKUP and RESTORE
commands (or other alternatives like tape backup systems) to copy entire hard disks to
other media.

 Many programs have their own commands for creating, copying, and deleting files. You
should learn what facilities your programs have for doing these MS-DOS functions.
Understanding MS-DOS helps you to better understand the programs you use.

MULTIMEDIA UNIVERSITY | 1
DCS5058 – OPERATING SYSTEMS MS DOS

MS-DOS Commands
1. Disk Commands

FORMAT:
Prepares a disk so that MS-DOS can use it. Formatting a disk erases all the information
on the disk, so be careful. Example: FORMAT A:
CHKDSK:
Checks for problems and repairs corrupted disks. A disk can sometimes get corrupted
when, for example, the power is turned off while a program is still running. Example:
CHKDSK C: /F
DISKCOPY:
Duplicates diskettes. Use this command to copy important diskettes, like newly
purchased programs. Example: DISKCOPY A: B:

2. Directory Manipulation Commands

MKDIR (MD):
Makes a directory on the disk. Example: MD C:\DOS
RMDIR (RD):
Removes empty directories from the disk. Example: RD C:\DOS
CHDIR (CD):
Changes the current working directory. Example: CD C:\DOS
PATH:
Provides a list of directories where MS-DOS can find programs. Put this in your
AUTOEXEC.BAT file. Example: PATH C:\;C:\DOS

3. File Copying & Backup Commands

COPY:
Copies files between disks or directories. Example: COPY C:\AUTOEXEC.BAT A:
XCOPY:
Copies files, or entire directories with their subdirectories, to other disks or directories.
Example: XCOPY C:\DOS C:\OLD_DOS /S
BACKUP:
Copies entire hard disks onto many floppy diskettes to create a backup copy of the hard
disk. Example: BACKUP C:\*.* A: /S /F
RESTORE:
Restores the BACKUP files back onto your hard disk. Example: RESTORE A: C:\*.*

MULTIMEDIA UNIVERSITY | 2
DCS5058 – OPERATING SYSTEMS MS DOS

4. File Management Commands

DIR:
Lists the files in a directory or disk. It includes file and directory names, file sizes, and
file creation dates. Example: DIR C:\
TYPE:
Displays the contents of a file on your computer screen. Example: TYPE
C:\CONFIG.SYS
ERASE (DEL):
Deletes files from the disk. Example: DEL C:\JUNK.TXT
RENAME (REN):
Changes the name of a file. Example: REN TEMPLATE.WP REPORT.WP

5. Other Commands

PROMPT:
Changes the MS-DOS command prompt from C> to whatever you wish. Use the
command PROMPT $P$G, to display your current working directory in the prompt.
DATE:
Displays and changes the current date. If your computer does not have a real-time clock
installed, put the DATE command in your AUTOEXEC.BAT file. Example: DATE
TIME:
Displays and changes the current time. If your computer does not have a real-time clock
installed, put the TIME command in your AUTOEXEC.BAT file. Example: TIME
MODE:
Changes various settings for the screen, serial ports, and printer ports. Example: MODE
CO40
EDIT:
A text editor used to modify files like AUTOEXEC.BAT and CONFIG.SYS. You can
also use word processors like WordPerfect. However, make sure you store the file in
TEXT mode, not in the word processor's native binary mode. Failure to do this could
seriously incapacitate MS-DOS. Make backup copies of system files before editing them.
Example: EDIT C:\AUTOEXEC.BAT

MULTIMEDIA UNIVERSITY | 3
DCS5058 – OPERATING SYSTEMS MS DOS

LEARNING THE BASIC MS-DOS

PART 2

This tutorial gives you an opportunity to try basic MS-DOS commands. By following the
procedures in this section, you will learn to:

1. What is Command Prompt


2. Typing Command
3. View the contents of a directory
4. Change from one directory to another
5. Create Directories
6. Delete Directories
7. Change from one drive to another
8. Create File
9. Copy files
10. Rename files
11. Delete files
12. Format a floppy disk

1. The Command Prompt

 When you first turn on your computer, you will see some cryptic information flash by. MS-
DOS displays this information to let you know how it is configuring your computer. You can
ignore it for now. When the information stops scrolling past, you'll see the following:

C:\>

 This is called the command prompt or DOS prompt. The flashing underscore next to the
command prompt is called the cursor. The cursor shows where the command you type will
appear.
 If your command prompt looks like the sample command prompt above, skip to the
following section, "Typing a Command."
 If your command prompt does not look like the example, type the following at the command
prompt, and then press ENTER:
 cd \
 Note that the slash leans backward, not forward. You will learn more about the cd command
later in the tutorial. If your command prompt still doesn't look like the example, type the
following at the command prompt, and then press ENTER:
 prompt $p$g
 Your command prompt should now look like the example.

MULTIMEDIA UNIVERSITY | 4
DCS5058 – OPERATING SYSTEMS MS DOS

2. Typing a Command

This section explains how to type a command at the command prompt and demonstrates the
"Bad command or file name" message.

 To type a command at the command prompt

1. Type the following at the command prompt (you can type the command in either
uppercase or lowercase letters):

nul

If you make a typing mistake, press the BACKSPACE key to erase the mistake,
and then try again.

2. Press ENTER.

You must press ENTER after every command you type.

The following message appears:

Bad command or file name

The "Bad command or file name" message appears when you type something that
MS-DOS does not recognize. Because nul is not a valid MS-DOS command, MS-
DOS displays the "Bad command or file name" message.

3. Now, type the following command at the command prompt:

ver

The following message appears on your screen:

MS-DOS version 6.22

The ver command displays the version number of MS-DOS.

Continue to the next section, where you will use the dir command to view the
contents of a directory.

MULTIMEDIA UNIVERSITY | 5
DCS5058 – OPERATING SYSTEMS MS DOS

3. Viewing the Contents of a Directory

In this section, you will view the contents of a directory by using the dir command. The dir
command stands for "directory."

 To view the contents of a directory

1. Type the following at the command prompt:

dir

A list similar to the following appears:

Volume in drive C is MS-DOS_6.22


Volume Serial Number is lE49-15E2
Directory of C:\

WINDOWS <DIR> 09-08-92 10:27p


TEMP <DIR> 05-15-92 12:09p
CONFIG SYS 278 09-23-92 10:50a
COMMAND COM 53014 09-18-92 6:00a
WINA20 386 9349 11-11-91 5:00a
DOS <DIR> 09-02-92 4:23p
AUTOEXEC BAT 290 09-23-92 10:54a

7 file(s) 62931 bytes


8732672 bytes free

This is called a directory list. A directory list is a list of all the files and subdirectories that a
directory contains. In this case, you see all the files and directories in the main or root directory
of your drive. All the files and directories on your drive are stored in the root directory.

MULTIMEDIA UNIVERSITY | 6
DCS5058 – OPERATING SYSTEMS MS DOS

4. Changing Directories

Look at the list on your screen. All the names that have <DIR> beside them are directories. You
can see a list of the files in another directory by changing to that directory, and then using the dir
command again. In this case, you will change to the DOS directory.

Before you begin this section, make sure you have a directory named DOS by carrying out the
following procedure.

o To make sure you have a directory named DOS

1. Look through the directory list on your screen for a line that looks similar to the
following:

DOS <DIR> 09-02-92 4:23p

2. If you see a line like this, you have a directory named DOS. Skip to the next
procedure, "To change from the root directory to the DOS directory."

If you do not see a line in the directory list indicating that you have a directory named
DOS, type the following at the command prompt:

dir /s memmaker.exe

You will see a message that includes a line such as the following:

Directory of C:\DIRNAME

If the name that appears in place of DIRNAME is DOS, you have a DOS directory.
Skip to the next procedure.

If the name that appears in place of DIRNAME is not DOS, substitute the name that
appears for DOS throughout this tutorial. For example, if the name that appears in
place of DIRNAME is MSDOS, type msdos whenever you are instructed to type dos.

o To change from the root directory to the DOS directory

To change directories, you will use the cd command. The cd command stands for "change
directory."

1. Type the following at the command prompt:

cd dos

The command prompt changes. It should now look like the following:

C:\DOS>
MULTIMEDIA UNIVERSITY | 7
DCS5058 – OPERATING SYSTEMS MS DOS

The command prompt shows which directory you are in. In this case, you know you
successfully changed to the DOS directory because the command prompt displays the
directory's name. Now the current directory is DOS.

Next, you will use the dir command to view a list of the files in the DOS directory.

o To view a list of the files in the DOS directory

1. Type the following at the command prompt:

dir

A list of the files in the DOS directory appears, but scrolls by too quickly to read. You can
modify the dir command so that it displays only one screen of information at a time.

o To view the contents of a directory one screen at a time

1. Type the following at the command prompt:

dir /p

One screen of information appears. At the bottom of the screen, you will see the
following message:

Press any key to continue . . .

2. To view the next screen of information, press any key on your keyboard. Repeat
this step until the command prompt appears at the bottom of your screen.

When you typed the dir command this time, you included the /p switch after the command.
A switch modifies the way MS-DOS carries out a command. Generally, a switch consists of
a forward slash (/) that is followed by one or more letters or numbers. When you used the /p
switch with the dir command, you specified that MS-DOS should pause after it displays each
screen of directory list information. The p actually stands for "page"

Another helpful switch you can use with the dir command is the /w switch. The /w switch
indicates that MS-DOS should show a wide version of the directory list.

o To view the contents of a directory in wide format

1. Type the following at the command prompt:

dir /w

The directory list appears, with the filenames listed in wide format. Note that only filenames
are listed. No information about the files' size or date and time of creation appears.

MULTIMEDIA UNIVERSITY | 8
DCS5058 – OPERATING SYSTEMS MS DOS

2. If the directory contains more files than will fit on one screen, you can combine the /p and /w
switches as follows:

dir /w /p

 Changing Back to the Root Directory

Next, you will change from the DOS directory to the root directory. The root directory is the
directory you were in before you changed to the DOS directory. Before you begin this section,
make sure your command prompt looks like the following:

C:\DOS>

o To change to the root directory

1. Type the following at the command prompt:

cd \

Note that the slash you type in this command is a backslash (\), not a forward slash
(/).

No matter which directory you are in, this command always returns you to the root
directory of a drive. The root directory does not have a name. It is simply referred to
by a backslash (\).

The command prompt should now look like the following:

C:\>

When your command prompt appears similar to this---that is, when it does not
contain the name of a directory---you are in the root directory.

MULTIMEDIA UNIVERSITY | 9
DCS5058 – OPERATING SYSTEMS MS DOS

5. Creating a Directory

In this section, you will create two directories. Creating a directory is helpful if you want to
organize related files into groups to make them easy to find. Before you begin this section, make
sure the command prompt looks like the following:

C:\>

To create a directory, you will use the md command. The md command stands for "make
directory."

o To create and change to a directory named FRUIT

1. Type the following at the command prompt:

md fruit

You have now created a directory named FRUIT. You won't see the new FRUIT
directory until you carry out the dir command in the next step.

2. To confirm that you successfully created the FRUIT directory, type the following
at the command prompt:

dir

or

dir /p

Look through the directory list. A new entry somewhere in the list should look similar
to the following:

FRUIT <DIR> 09-25-93 12:09p

3. To change to the new FRUIT directory, type the following at the command prompt:

cd fruit

The command prompt should now look like the following:

C:\FRUIT>

You will now create a directory within the FRUIT directory, named GRAPES.

o To create and work with a directory named GRAPES

MULTIMEDIA UNIVERSITY | 10
DCS5058 – OPERATING SYSTEMS MS DOS

1. Type the following at the command prompt:

md grapes

You will not see the new GRAPES directory until you carry out the dir command in the next
step.

2. To confirm that you successfully created the GRAPES 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-25-93 12:08p


.. <DIR> 09-25-93 12:08p
GRAPES <DIR> 09-25-93 12:10p
3 file(s) 0 bytes
11534336 bytes free

Note that there are three entries in the FRUIT directory. One is the GRAPES directory that
you just created. There are two other entries---one looks like a single period (.) and the other
looks like a double period (..). These directory entries are important to MS-DOS, but you can
ignore them. They appear in every directory and contain information relation to the directory
structure.

The GRAPES directory is a subdirectory of the FRUIT directory. A subdirectory is a


directory within another directory. Subdirectories are useful if you want to further subdivide
information.

3. To change to the GRAPES directory, type the following at the command prompt:

cd grapes

The command prompt should now look like the following:

C:\FRUIT\GRAPES>

4. To switch back to the FRUIT directory, type the following:

cd ..

The command prompt should now look like the following:


MULTIMEDIA UNIVERSITY | 11
DCS5058 – OPERATING SYSTEMS MS DOS

C:\FRUIT>

When the cd command is followed by two periods (..), MS-DOS moves up one level
in the directory structure. In this case, you moved up one level from the GRAPES
directory to the FRUIT directory.

6. Deleting a Directory

If you no longer use a particular directory, you may want to delete it to simplify your directory
structure. Deleting a directory is also useful if you type the wrong name when you are creating a
directory and you want to delete the incorrect directory before creating a new one.

In this section, you will delete the GRAPES directory. Before you begin this section, make sure
the command prompt looks like the following:

C:\FRUIT>

To delete a directory, use the rd command. The rd command stands for "remove directory."

o To delete the GRAPES directory

1. Type the following at the command prompt:

rd grapes

2. To confirm that you successfully deleted the GRAPES directory, type the following at the
command prompt:

dir

The GRAPES directory should no longer appear in the directory list.

Note You cannot delete a directory if you are in it. Before you can delete a directory,
you must make the directory that is one level higher the current directory. To do this,
type cd.. at the command prompt.

MULTIMEDIA UNIVERSITY | 12
DCS5058 – OPERATING SYSTEMS MS DOS

7. Changing Drives

This section describes how to change drives. Changing drives is useful if you want to work with
files that are on a different drive.

So far, you have been working with drive C. You have other drives you can use to store
information. For example, drive A is your first floppy disk drive. The files and directories on
drive A are located on the floppy disk in the drive. (You might also have a drive B, which
contains the files and directories stored on the floppy disk in that drive.)

Before you begin this section, make sure your command prompt looks like the following:

C:\FRUIT>

o To change to and view files on a different drive

1. Insert a 3.5" floppy disk in drive A label- side up. Make sure the disk clicks into
the drive.

1. Type the following at the command prompt:

a:

Note that the command prompt changed to the following:

A:\>

This message may appear:

Not ready reading drive A

Abort, Retry, Fail?

If you see this message, the disk may not be inserted properly. Place the disk label-side up in
the disk drive, and make sure the disk clicks into the disk drive. Then, type r for Retry. If this
message appears again, press F for Fail, and then type b: at the command prompt. If you no
longer see this message, type b: instead of a: throughout the rest of the tutorial.

There must be a floppy disk in the drive that you want to change to.

2. To view a list of the files on the floppy disk in drive A, type the following at the command
prompt:

dir

A list of the files on the disk appears.

MULTIMEDIA UNIVERSITY | 13
DCS5058 – OPERATING SYSTEMS MS DOS

3. Change back to drive C by typing the following at the command prompt:

c:

Your command prompt should return to the following:

C:\FRUIT>

When you type a drive letter followed by a colon, you change to that drive. The drive letter
that appears in the command prompt shows which drive is the current drive. Unless you
specify otherwise, any commands you type are carried out on the current drive and in the
current directory.

So far, all the commands you typed were carried out on the current drive and in the current
directory. You can also carry out a command on a drive that isn't current. For example, you
can view the files on a disk in drive A without switching to drive A by following this
procedure.

o To view files on drive A when drive C is current

1. Type the following at the command prompt:

dir a:

A list of the files on the floppy disk in drive A appears, even though your command
prompt indicates that drive C is current.

By specifying a: after the dir command, you are giving MS-DOS additional information.
You are indicating that you want the dir command to show the list of files and directories on
drive A instead of drive C. The a: you typed after the dir command is called a parameter. A
parameter specifies what a command should act on. In the previous example, the parameter
you used indicated which directory list you want to view.

The following procedure presents another example of using a parameter.

o To view the contents of the DOS directory on drive C

1. Type the following at the command prompt:

dir c:\dos

A list of the files in the DOS directory on drive C should scroll past on your screen.

The c:\dos parameter specifies that you want MS-DOS to display the contents of the DOS
directory on drive C, even though your command prompt indicates that the FRUIT directory
is current.

MULTIMEDIA UNIVERSITY | 14
DCS5058 – OPERATING SYSTEMS MS DOS

8. Create a file

Create a File with DOS

Directions:

1. Type: copy con Quick.ltr and press return.

2. Type this message in the following format:

Bob

Sales are up 15%.

Good Job!

Craig

3. Press the F6 function key (^Z) and press return.

4. DOS gives you a message that 1 File(s) has been copied.

5. Type: dir q* and press return.

6. Now you can see the list of files beginning with the letter Q.

NOTE: You can also use the COPY command to print a file by typing: copy quick.ltr prn and
press return.

List the content

Type a File with DOS

If you need to check the contents of a particular file or any DOS file, you will need to use the
TYPE command.

Directions:

1. Type: type quick2.ltr and press return.

2. DOS prints the contents of the file.

NOTE: Never use the TYPE command with files that have the .com, .exe, .sys, and .bas
extensions. These are program files and will only display junk on the screen.

MULTIMEDIA UNIVERSITY | 15
DCS5058 – OPERATING SYSTEMS MS DOS

9.Copying Files

This section describes how to copy a single file and a group of files. Copying files creates a
duplicate of the original file and does not remove the original file. This is useful for many
reasons. For example, if you want to work on a document at home, you can copy it from your
computer at work to a floppy disk and then take the floppy disk home.

To copy a file, you will use the copy command. When you use the copy command, you must
include two parameters. The first is the location and name of the file you want to copy, or the
source. The second is the location to which you want to copy the file, or the destination. You
separate the source and destination with a space. The copy command follows this pattern:

copy source destination

 Copying a Single File

In this section, you will copy the EDIT.HLP and EDIT.COM files from the DOS directory to
the FRUIT directory. You will specify the source and destination of these files in two
different ways. The difference between the two methods is explained at the end of this
section.

Before you begin this section, make sure the command prompt looks like the following:

C:\FRUIT>

To copy the EDIT.HLP and EDIT.COM files from the DOS directory to the FRUIT directory

1. Return to the root directory by typing the following at the command prompt:

cd\

The command prompt should now look like the following:

C:\>

Change to the DOS directory by typing the following at the command prompt:

cd dos

The command prompt should now look like the following:

C:\DOS>

2. Make sure the file you are going to copy, EDIT.COM, is located in the DOS directory by
using the dir command followed by a filename. To see if the EDIT.COM file is in the DOS
directory, type the following at the command prompt:

MULTIMEDIA UNIVERSITY | 16
DCS5058 – OPERATING SYSTEMS MS DOS

dir edit.com

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

EDIT Com 413 03-25-93 5:00a

1 file(s) 413 bytes 11999232 bytes free

This shows that the EDIT.COM file is located in the DOS directory. You just specified
another parameter with the dir command, one that directs MS-DOS to list only the files that
match the filename you specified in the command. Since only one file in the DOS directory
can be named EDIT.COM, the directory list includes only that file.

3. To copy the EDIT.COM file from the DOS directory to the FRUIT directory, type the
following at the command prompt:

copy c:\dos\edit.com c:\fruit

The following message appears:

1 file(s) copied

The command you just typed copied the file from its source to its destination. By specifying
C:\DOS\EDIT.COM as the source, you indicated that MS-DOS would find the source file
EDIT.COM on drive C in the DOS directory. By specifying C:\FRUIT as the destination,
you indicated that MS-DOS should place the copy of EDIT.COM on drive C in the FRUIT
directory.

4. Next, you will copy the EDIT.HLP file to the FRUIT directory. To confirm that the
EDIT.HLP file is in the DOS directory, type the following at the command prompt:

dir edit.hlp

5. To copy the EDIT.HLP file from the DOS directory to the FRUIT directory, type the
following at the command prompt:

copy edit.hlp \fruit

The following message appears:

1 file(s) copied
MULTIMEDIA UNIVERSITY | 17
DCS5058 – OPERATING SYSTEMS MS DOS

If you forgot to leave a space before typing fruit, the following message will appear:

Access denied

If this message appears, type the command again and leave a space before fruit.

6. To confirm that you copied the files successfully, view the contents of the FRUIT directory
by typing the following at the command prompt:

dir \fruit

You should see the two files listed in the FRUIT directory.

Note that you specified the source and destination in the two copy commands differently. In the
command you typed in step 4, you specified the source file as C:\DOS\EDIT.COM and the
destination directory as C:\FRUIT. Both C:\DOS\EDIT.COM and C:\FRUIT are called full paths
because you specified the drive and directory where these files are located. Specifying the full
path is the safest way to copy files, because you provide all the information about which file you
want to copy and which directory you want to copy it to.

In the copy command you typed in step 6, you specified EDIT.HLP for the source file and
FRUIT for the destination directory. These are relative paths. A relative path specifies only the
difference between the current drive and directory and the destination of the files you are
copying. The following illustration shows how the DOS directory and the FRUIT directory are
related:

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

MULTIMEDIA UNIVERSITY | 18
DCS5058 – OPERATING SYSTEMS MS DOS

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.

9.1 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.
MULTIMEDIA UNIVERSITY | 19
DCS5058 – OPERATING SYSTEMS MS DOS

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.
MULTIMEDIA UNIVERSITY | 20
DCS5058 – OPERATING SYSTEMS MS DOS

10. 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.

10.1 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

MULTIMEDIA UNIVERSITY | 21
DCS5058 – OPERATING SYSTEMS MS DOS

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.

MULTIMEDIA UNIVERSITY | 22
DCS5058 – OPERATING SYSTEMS MS DOS

11. 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 PEAR.COM 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

MULTIMEDIA UNIVERSITY | 23
DCS5058 – OPERATING SYSTEMS MS DOS

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.

MULTIMEDIA UNIVERSITY | 24
DCS5058 – OPERATING SYSTEMS MS DOS

12. 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.

MULTIMEDIA UNIVERSITY | 25
DCS5058 – OPERATING SYSTEMS MS DOS

Volume Serial Number is lE49-15E2 Format another (Y/N)?

3. 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.

Notes taken from

 http://www.tnd.com/camosun/elex130/dostutor1.html
 http://www.glue.umd.edu/~nsw/ench250/dostutor.htm
 http://www.computerhope.com/batch.htm

MULTIMEDIA UNIVERSITY | 26

You might also like