Ms Dos
MicroSoft Disk Operating System



Source of this page

Author:Thibaut Bernard

Number of visitor

Update: Sunday 6 April 2003.

Alphaquark author's Note :
This page is a translation of Msdos with the help of Altavista translation.
I hope this translation is good, but if there are any errors, you can write me.
If this translation is successful, perhaps I will try to translate another document of Alphaquark.




Selection of one or more files
Attributes of file
Management of directory
Management of file
Catalogue (listing of the file names stored on mass memory)
Visualization of the contents of a textual file
Virtual drive


The batch

Instruction echo
Command choice
Command shift


Glossary (in french)






To be able to manage the files on the mass memories, the computer needs a software called: operating system of which here principal valid commands on all the computers PC compatible.

Each command must be validated by the key 'Enter' (Carriage Return according to the keyboards).


Selection of one or more files

All the commands followed by a space then various following syntaxes, will act on the selected files:

NOM.EXT Selection of a file which one specifies the NAME and EXTension.

*.EXT Selection of all the files which one specifies EXTension.

B*.* Selection of all the files whose name starts with B.

C*.EXT Selection of all the files whose name starts with C and which one specifies EXTension.

*.* Selection of all the files without exception.


Attributes of files

The four attributes which interest us here are: Reading alone, files, hidden, and system. We will see the three first.


ATTRIB toto.doc +r Activates the reading alone with the file toto.doc. One cannot erase any more this file with the command erase.

ATTRIB toto.doc -r Desactive reading alone with the file toto.doc.

ATTRIB toto.doc Display the attributes of the file toto.doc.

ATTRIB *.* Display attributes of all the files.

ATTRIB *.* +r /s Put all input files alone including the files located in under directories (parameter /s).

Parameters: Reading alone +r or -r, files +a or -a, hidden +h or -h, and system +s or -s.

The attribute "reading alone" makes it possible to avoid erasing by error such or such file by the command erase. It's necessary to give this attribute to -r to inhibit it.

The hidden attribute (ATTRIB toto.doc +h for activated this attribute on the file toto.doc) makes it possible the file not to be displayed at the time of a listing of files (command DIR).

The attribute file indicate if the file were modified since its last backup. This attribute is useful for command XCOPY seen further.

The attribute system indicate to the operating system if such or such file is a file forming part of those used by the operating system. In practice we do not have to serve to us directly as this attribute nor of the files reserved by MS-DOS.


Management of directories

See the chapter on the directories.

CD\ (Type CD + Alt 92) Return to the principal directory.

CD.. Return to the preceding directory.

CD WORD Open the directory WORD.

MD NAME Creation of the directory NAME.

RD NAME Delete of the directory NAME. With beforehand one must open the file and erase all the files being in this file (including under directories), then to return to the root comprising this file.

DELTREE (MSDOS 6 and superior). Delete a directory even if it contains files.


Management of the files

Copy files (transfer of one or more files, a reader with another or a file with another) :

COPY C:NOM.EXT A: Copy of a file being from the reader C, towards the reader A and which one specifies the NAME and EXTension.

COPY C:*.COM A: Copy of all the files being from the reader C and whose extension is COM, on reader A.

COPY A:X *.* C: Copy of all the files being from the reader A and whose names starts with X, on the reader C.

COPY A:*.* C: Copy of all the files being from reader A, the reader C.

COPY A.TXT+B.TXT C.TXT Amalgamates files A.TXT and B.TXT in only one in a third file C.TXT.

XCOPY A:*.* C: Is equivalent to the preceding command (COPY) but to the difference close which it allows some additional options as we will see it.

XCOPY A:*.* C: /S Copie of all the files being from reader A, the reader C but by including there the files located in under directories (option /S).

XCOPY A:*. * C: /S /M Idem that the preceding command but delete decontaminating the attribute files. In this case XCOPY (with the option /M) copies only the files whose attribute file is activated. For ten files (of which the total capacity would not be in the same way 20 KB) that does not certainly have great interest. But where one smells the utility it, it is in the case of a lodging server of the thousands (see tens of thousands) of files whose total capacity amount to hundreds of million bytes. It is obvious that that is much fast to rather back up only few tens of files modified during the day than to be obliged all to back up each time.

Renaming of a file :


Erasure of files :

ERASE NOM.EXT Delete a file which one specifies the NAME and EXTension.

ERASE *.BAK Delete all the files whose extension is BAK.

ERASE *.* Delete all the files. In this case, ms DOS asks us to confirm the erasure by typing Y (yes) to confirm the request for erasure, or N (not) to cancel the request.


Catalogue (listing of the file names stored on mass memory)

DIR Catalogues of the current drive.

DIR A: Catalogue of reader A (idem for B and C).

DIR *.COM Catalogues of all the files whose extension is COM.

DIR X:*.* Catalogue of all the files whose name starts with X.

In this case one obtains the list of all the files with their co-ordinates, cuts, date and hour of the last backup of the files. There are two options which make it possible to differently present the list of these files (/P and /W).

Options of DIR

DIR /S Displays also the contents of under directory.

DIR /W Displays only the name of the files on five columns.

DIR /P If the number of files is not due to the screen, /P mark a pause before displaying the continuation.

DIR /B Gives only the name of the files without their co-ordinates (size and date).

One can of course combine these options. Example:

DIR *.DOC /S /P Display the files whose extension is DOC while including there under directories and by marking a pause in the run of the list of the files.


Visualization of the contents of a textual file

TYPE NOM.EXT Sending with the screen contents of the file nom.ext. This file being with the format text such as the batch where txt.

MORE < NOM.TXT Idem that previously but with the difference that visualization marks a pause before displaying the continuation of the text if the file does not hold on a screen.



After the commands DIR and STANDARD, if command PRN > is specified, that will send to the printer the list files (DIR) or the contents of a file (STANDARD):

DIR > PRN. Printing of all the list of the files.

DIR * DOC > PRN. Printing of all the list of the files whose extension is DOC.

TYPE NOM.EXT > PRN. Printing of the contents of a file which one specifies the NAME and EXTension.


Virtual drive

We can attribute a letter at a directory for that it to be seen as a drive.
Example, instead of to do dir c:\toto, we can do dir e:.
Dir e: list the files of c:\toto.

The instruction is subst. Syntaxe : subst drive directory.


subst e: toto, attribute the letter e at the directory toto.
subst, list the letters associated at the directory.
subst e: /d, delete the relation between the letter and the directory.


When we attribute the letter at the directory, we must to put the whole directory. Example : subst e: c:\toto.
We can use subst e: toto, but if at this moment we are in the directory c:\document, the drive e: will are attributed at c:\document\toto and not at c:\toto.
For the example, after to have did subst e: toto when you are in the directory c:\document, at the next copy a:*.* e:, the files will are copied in c:\document\toto and not in the directory c:\toto.
It's the reason why you must to put the whole directory (subst e: c:\toto) for to be certain that the new drive select the good directory (c:\toto in our example).

We can put the subst in the autoexec.bat if we wish a automatical relation for the letter at the directory when the computer start.



CLS Erasure of the screen.



The batch


The batch are files which allow the processing in batch of commands MSDOS. If there is a succession of commands which one must regularly carry out, one places these commands in a file called batch. One can thus put at it all the commands of the cls type, cd... ; but certain instructions (which we will see) are specific to the batch.

These files batch have the extension "bat" and are with the format text, therefore being able to be to create with any text editor recognizing the ASCII.


Instruction echo

This instruction is used for two things, to display text with the screen and to require to display or not the continuation of the instructions to be carried out.

The sign arrobas (@) makes it possible not to display the instruction in the course of execution. Example : the instruction "@copy toto titi" copies the file toto in a file titi but without displaying the instruction "copy toto titi".

To avoid having to put the arrobas at all the instructions, we can put @echo off. The instruction is execute but not to display. The instruction "@echo on" restore the display.

The instruction "@echo." print a empty line.

The instruction "@echo toto" print the text toto.

Example :

@echo off
echo Hello
echo toto

Result :




Instruction exist

Example 1 :

if exist toto echo The file toto exist.
if not exist toto echo The file toto don't exist.

The first line (if exist) test if the file exist.
The second line (if not exist) test if the file don't exist.
In the two case, the test if print the good message.

Example 2 :

if not exist rep md rep.

If the folder don't rep exist, then rep is created.

Example 3 :

if exist toto goto next
rem Put here the instruction at to do if the file (or the directory) toto don't exist.

Here, we go at next if the file toto exist, else the instruction following the test if is did.

This examples test if a file exist. For to test if a folder exist, we must put the parameter \nul after the name of folder. Example for to test if the folder toto exist :

if exist toto\nul goto suite
echo toto don't exist
goto fin
echo toto exist


Command choice

The command choice ask the user to push a letter among the letter proposed. The letter selected is tested by the command errorlevel.

Option :

/C[:]keys: Specify the keys at to propose. It's YN (Yes or No) if the keys aren't specified.
/N : Don't print the keys and the ?.
/S : The difference between the capital and the small letter are did.
/T[:]c,nn : The key "c" is choice if the use don't push a key after nn second.

Example (menu.bat) :

@echo off
echo d) execute defrag
echo s) execute scandisk
echo q) quit
choice /c:sdq What do you want
if errorlevel = 3 goto fin
if errorlevel = 2 goto def
if errorlevel = 1 goto scan
goto menu
goto menu

This batch is execute until we push the key q. Else it's the soft defrag when we push d and scandisk when it's s.



The directive %1 (sign percent and a number from 1 at 9) give the nine parameters that the batch accept.

Example : If the batch x.bat have the command "echo %1", if we type "x toto" then the word toto will are printed.

Example with the test if :

if "%1"=="toto" goto xxx
goto end
echo You have taped toto.

Warning, the test if do the difference between the capital and the small letter. In our example, if we type Toto, the message (You have taped toto.) isn't printed.


Command shift

This command shift the parameters. The first parameter take the value of the second, the second take the value of the third, until the last (the ninth). After the last is empty.

Example of application :

We want copy all the files with the extension that the user want.

Batch :

if "%1"=="" goto finish
copy *.%1 a:
goto again

Example : batch txt doc.

Remark :

The instruction if test if the first parameter is empty. In this case we go the end of the batch.
Else the batch copy the file with the extension given by the first parameter (%1), shift the parameter and to go at again for the next extension.

With this instruction if, the batch copy the files until the first parameter are empty.



In the batch, we can put all the commmand msdos (attrib, copy, dir...)




ms-dos 6.22. Documentation most detailed for msdos 6.22 (but in french).