Monday, October 25, 2010

DOS Commands


Directory Manipulation

     MD or MKDIR  -  creates a directory
     CD or CHDIR  -  changes directory
     PROMPT  -  changes the command prompt
     TREE  -  displays the directory structure
     RD or RMDIR  -  removes a directory
     Renaming directories
     PATH  -  creates a search path


MD or MKDIR  -  creates a directory

The MD or MKDIR  command is used to create subdirectories in the root directory or other subdirectories.

Command  Syntax:     MD      DRIVE:\PATH\DIRECTORY

Example  1:     Create a subdirectory named DOCS in the root directory of C

                                    MD      C:\DOCS

Example  2:     Create a subdirectory of the DOCS subdirectory called WORK

                                    MD      C:\DOCS\WORK

Example  3:     Create a subdirectory of WORK called TEMP

                                    MD      C:\DOCS\WORK\TEMP

Example  4:     If you were already in the WORK directory (see next section re changing directory) the following would be sufficient to create the TEMP subdirectory

                                    MD      TEMP

CD or CHDIR  -  changes directory

The CD or CHDIR command is used to move from one directory to another; or to show the current directory path (i.e. the hierarchy of directories from the root directory to the one you are currently working in). The directory you are currently in is known as the current or default directory. When you move to another directory it becomes the current directory. Once your system has booted your initial current directory will normally be the root.

Command Syntax:      CD      DRIVE:\PATH
                        or         CD     


DOS uses the following ‘special’ characters to reference particular directories within the directory structure and these can also be used with the CD command.

                        \           -           the Root Directory
                        .           -           the Current Directory
                        ..          -           the Parent Directory of the current directory


Example  1:     Move to the subdirectory TEMP (assuming it exists)

                                    CD      C:\DOCS\WORK\TEMP

Example  2:     Display  the path to the current directory (i.e. Current Directory Path)

                                    CD                 

Example  3:     Move to the parent directory of the current directory

                                    CD   ..

Example  4:     Move back to the subdirectory TEMP (this example assumes you are currently in subdirectory WORK; use example 2 to check before moving)

                                    CD      TEMP

Example  5:     Move to the root directory. (This will make the root the current directory)

                                    CD   \


PROMPT  -  changes the command prompt

It is useful if you can see immediately from the command/screen prompt what directory you are currently working in (i.e. the current directory) and the path to that directory. The PROMPT command enables you to do this.

To make the command prompt show the path to the current directory, and not just the letter representing the default disk drive, type

                                    PROMPT  $P$G

Your AUTOEXEC.BAT file may already include this command line, if not it can be edited to do so. In this way a useful prompt will be set up every time you start a new session on your computer.

After typing PROMPT $P$G as indicated, move up and down through the directory structure to see how the prompt changes.


TREE  -  displays the directory structure

The TREE command enables the user to obtain a graphical view of the structure of directories and subdirectories on a disk.

Command Syntax:      TREE              DRIVE:\PATH           /SWITCH

                                    Where SWITCH is

                        F          -           Display the names of files in each directory


Example  1:     Display the structure of the DOCS directory

                                                            TREE              C:\DOCS

Example  2:     Display the directory structure and files of C

                                                TREE              C:        /F


RD or RMDIR  -  removes a directory

RMDIR or RD is used to remove a directory. This command will only work if the directory concerned is empty.

Command Syntax:      RD      DRIVE:\PATH\DIRECTORY


Example:         Remove the empty subdirectory of C:\DOCS\WORK called TEMP

                        RD      C:\DOCS\WORK\TEMP

DOS 6 introduced the DELTREE command which allows you to delete directories whether or not they are empty. (i.e. it allows you to delete all the files and subdirectories in a directory plus the directory itself with a single command.) This command should be used with care.


Renaming directories

In DOS 5 there is no single command that allows you to rename a directory. You have to use a combination of the MD, XCOPY, DEL and RD commands. This has been addressed in DOS 6 with the introduction of the MOVE command which can be used to rename directories or move files. (For DOS 5 renaming directories is simpler with DOSSHELL - see later.)


PATH  -  creates a search path

For many DOS commands (viz. external commands) there is a program file which has to be executed in order for the command to work. In the examples so far we have assumed that this is not a problem but in fact DOS has to know where on disk, i.e. in which directory, the corresponding program file is. If it cannot find the file then the command will fail.

By default DOS will only look in the current directory for this program/executable file. If it is not there then DOS has to be know the path (i.e. the hierarchy of directories from the root) to it.

This can be achieved by prepending the relevant path to the command name whenever composing a command line. However it would be better if DOS could simply be told in which directories to look for program files whenever a command name was entered. This can be achieved by using the PATH command. It enables you to specify the path to directories DOS should search, after the current directory for the program file for a command. Once this command has been issued DOS will remember these directories until the command is used again either to clear the search path or set a new search path, or until the machine is switched off.

Command Syntax:      PATH             DRIVE:\PATH

You can have multiple occurrences of DRIVE:\PATH each separated by   ;


Example  1:     Set a path to  \  (the root directory), and the DOS directory

                                    PATH C:\;C:\DOS

This instructs DOS that after it has searched the current directory for a program file, it should then search the root directory of C: and then the DOS subdirectory of the root.

This should be a minimum search path when using DOS because most of the DOS program files are usually kept in the DOS subdirectory and the root directory. It allows the DOS commands to be used, as in these notes, without prepending them with a path.

A search path containing at least these elements is usually set up in the AUTOEXEC.BAT.

Example  2:     Add the directory MEMOS on the diskette to the search path

                                    PATH             C:\;C:\DOS;A:\MEMOS


You can also use the PATH command to see what directories are currently in the search path, and to clear it.

Example  3:     Display the current search path

                                    PATH

Example  4:     Clear the search path

                                    PATH ;



File Manipulation

      DIR  -  Lists files and subdirectories
·      Wildcard Characters   ?   *
     EDIT  -  creates a new file or modifies an existing file
     COPY  -  copies a file or a group of files
     XCOPY  -  copies all files in a directory (and its subdirectories)
     DEL or ERASE  -  deletes a file or a group of files
      UNDELETE  -  undeletes files
     COPY (or XCOPY) plus DEL  -  moves files
     DOSKEY  -  recalls commands
     RENAME or REN  -  renames files
     TYPE  -  displays text files
     PRINT  - prints a text file
     COPY  -  used to create a file
     ATTRIB  -  sets file properties
     FC  -  compares two files


DIR  -  Lists files and subdirectories

This command lists the names of files and directories in the current directory, or one specified in the command line. It can also provide additional information such as the amount of free space on the disk, the dates directories were created, and the dates files were last modified and there sizes.

It is also possible use DIR to search for specific files.

Command Syntax:      DIR     DRIVE:\PATH\DIRECTORY          /SWITCHES
                                                                          FILE

                                    Where SWITCHES are

                        P          -           page through the listing one screen at a time
                        W        -           produce a wide listing
                        S          -           execute the command in subdirectories of the
                                                subject directory as well as the directory itself
                        A:x      -           list only files with attribute x
                                                where x = h (hidden), r (read only), s (system)                                               O:y      -            order the listing according to  y
                                                where y = n (name), e (extension), s (size),
                                                                d (date and time - earliest first)
                        B         -           blank out heading and summary information


Example  1:     List the contents of the root directory of the floppy disk

                                    DIR     A:\

Example  2:     Produce a wide listing of the current directory of C one page at a time

                                    DIR     C:        /P         /W

Example  3:     List every occurrence of the file AUTOEXEC.BAT in the current directory                                   and its subdirectories

                                    DIR     AUTOEXEC.BAT     /S

Example  4:     List the contents of the DOS directory in chronological order

                                    DIR     C:\DOS           /O:D

Example  5:     List only those files in the root of C which are hidden

                                    DIR     C:\       /A:H


Wildcard Characters   ?   *

A Wildcard Character is a character which has special meaning. In DOS wildcards are the  *  (the asterisk) and  ?  (the question mark ). They are usable with many DOS commands. The question mark represents any single character, and the asterisk a string of characters. Wildcards enable you to do more with the basic commands.

As examples, suppose you wanted to use the DIR command to list only the files that ended with a particular extension, or started with a particular word.


Example  1:     Display only those files in the root of C whose name ends with the .COM extension

                                    DIR     C:\   *.COM

Example  2:     Display those files in the DOS directory which start with DISK, are followed by 4 characters, and have any extension.

                                    DIR     C:\DOS\DISK????.*

You should get into the habit of using the DIR after you have executed a command (e.g. the MD or CD commands discussed above, or the COPY, DEL etc. commands below) to confirm the effects of that command.


EDIT  -  creates a new file or modifies an existing file

To create a text file in DOS you invoke the Screen Editor by using the EDIT command.

Command Syntax:      EDIT   DRIVE:\PATH\ FILE

                        FILE   must be an unformatted ASCII text file

Carry out the following steps to create your own file; this will give you a file on which to practice the other commands.

Type EDIT <return> at the DOS  prompt.
Once in the editor press the ESC key.

You should get the following screen



Then type in the bold text below, using your own name where it says your name. This text will constitute the contents of the file.

(If you make a mistake while typing use the following keys to make corrections. - The Delete and BackSpace keys to remove letters; the ¬,  ®, ­, ¯ (Arrow) keys to position the Cursor without removing letters; and the Insert key to switch between Insert and Over Write mode.)
           
            @echo off
            echo.
            echo   GOOD DAY   your name
            echo.

Once you have finished press the Alt key which, as indicated at the bottom of the screen, activates the menus.
You will see the first letters of the Menu Items at the top of the screen become illuminated. The File item should be highlighted. If not use  ¬  and  ®  to highlight it. Press the Return or Enter key to activate the File Menu.
Use  ¯  to move the Menu Bar down to Save As, and press <return> to select this option.
Type in the file name HELLO.BAT <return>.
You have now created a file called HELLO.BAT, containing the above text.
Now leave the Editor by activating the File Menu, and then selecting Exit.

The file you have just created is a simple Batch file - i.e. a file of DOS commands which will be executed, one after the other, simply by typing in the name of the file (without the .BAT extension).

To run this batch file type HELLO <return> at the DOS prompt.
The message Good Day should appear.


The Editor provides an easy method of creating a new text file. It is particularly useful for creating DOS batch files (which are special text files). If you want to modify/edit an existing text file then you simply supply the name of that file as a parameter to the command. Once in EDIT you can use a mouse, or simply the keyboard, to highlight text, cut (or copy) and paste that text, select menu items, etc. Most of the commands in EDIT are self explanatory and easy to use.

Example:         Edit the batch file you have just created.

                                    EDIT   HELLO.BAT


COPY  -  copies a file or a group of files

The COPY command enables you to make copies of files. It may be used to make a copy within a particular directory, to copy from one directory to another and to copy from one disk to another. You can use the command to copy one file by using its filename, or several files by using the DOS wildcard characters  *  and/or  ?

Command Syntax:   COPY    DRIVE1:\PATH1\ FILE1(S)    DRIVE2:\PATH2\ FILE2(S)

Example  1:     Copy one file from drive C to drive A

                                    COPY             C:\HELLO.BAT         A:

Example  2:     Make a copy of a file within the same directory. You have to give the copy a different name. e.g. GREETING.BAT

                                    COPY             A:\HELLO.BAT         A:\GREETING.BAT

Example  3:     Copy all the files in the root of A to a directory on the hard drive

                                    COPY             A:\*.*              C:\DOCS

Now use the DIR command to list the files on drive A again.


XCOPY  - copies all files in a directory (and its subdirectories)

The XCOPY command behaves in the same way as the COPY command, however it allows the copying of all the files in a directory, and also its subdirectories.

Command Syntax:

XCOPY          DRIVE1:\PATH1\DIRECTORY      DRIVE2:\PATH2       /SWITCHES
                                                      FILES

                                    Where SWITCHES are

                        S          -           copy subdirectories which contain files
                        E          -           also copy empty subdirectories (/E is used with /S)
                        D:date -           only copy files changed after a certain date


Example  1:     Copy the contents of the DOCS directory, and its subdirectories, including empty ones, to directory TEMP-DIR on A

                                    XCOPY          C:\DOCS        A:\TEMP-DIR            /S         /E

DOS will allow you to create the TEMP-DIR if it does not already exist.


Example  2:     Copy all the files in the root directory of C modified on or after 1/1/96 to A

                                    XCOPY          C:\*.*              A:        /D:1/1/96


Example  3:     Copy all the files in the A drive's TEMP-DIR directory to a directory with the same name on the C drive

                                    XCOPY          A:\TEMP-DIR            C:\TEMP-DIR


DEL or ERASE  -  deletes a file or a group of files

The DEL or ERASE commands perform the same operation; you can use either.


Command Syntax:      DEL    DRIVE:\PATH\FILE(S)        /P

The P switch causes DOS to prompt the user with the name of the file to be deleted, to confirm that this is really his intention, before actually carrying out the deletion.
If the P switch is omitted then the deletion is carried out silently.


Example  1:     Prompt the user with the name of each file in the current directory that has the extension .BAK, and ask him to confirm whether it should be deleted

                                    DEL    *.BAK                        /P

Example  2:     Delete the file HELLO.BAT from the DOCS directory

                                    DEL    C:\DOCS\HELLO.BAT

Example  3:     Delete all files in the root of A

                                    DEL    A:\*.*

Whenever the wildcard character is used in this manner, the user is always reminded that all files in the directory will be deleted, and asked to confirm Yes or No.


Warning

NEVER delete the file COMMAND.COM file since it is the file which enables DOS  commands to run.

Be very careful when using wildcard characters with the DEL/ERASE command, as you will not be asked to confirm the deletion of individual files when using it (unless you use the /P switch) and so may delete a file which you really need to keep. You should always use DIR to list the contents of the directory before you start deleting using wildcards, to see exactly what files will be affected.





UNDELETE  -  undeletes files

The UNDELETE command, which was not available before DOS 5, attempts to undo the use of DEL. It provides a degree of protection against accidental deletion of files. UNDELETE relies on the fact that DELeting a file does not physically remove it but simply marks the area of disk concerned as available for reuse. Thus once you have deleted a file you will not see it if, for example, you execute the DIR command but providing it has not been subsequently overwritten it should be recoverable using UNDELETE.

Command Syntax:      UNDELETE   DRIVE:\PATH\FILE(S)        /SWITCHES

                                    Where SWITCHES are

                        LIST    -           list all files deleted which have not been subsequently
                                                overwritten
                        ALL    -           undelete all deleted files without prompting the user


Example  1:     Undelete the file called HELLO.BAT which has been deleted from the A drive

                                    UNDELETE               A:\HELLO.BAT

If recoverable the dialogue will be continue something like this -

                        Directory:  A:\
                        File Specifications: HELLO.BAT

                              Deletion-tracking file not found.

                              MS-DOS directory contains    1 deleted files.
                              Of those,    1 files may be recovered.

                        Using the MS-DOS directory method.

                              ?ELLO   BAT    49   1/1/96   16:23    ...A  Undelete (Y/N)?    Y
                              Please type the first character for ?ELLO  .BAT:                        H

                        File successfully undeleted.


Example  2:     Undelete all files that are recoverable in the current directory

                                    UNDELETE




COPY (or XCOPY) plus DEL  -  moves files

DOS 5 does not have a specific command for moving files (DOS 6 does) but this can be achieved by using the COPY (or XCOPY) and DEL commands. i.e. Making copies and then deleting the originals.

Example:         Move all the document files in the root directory of drive C to drive A

                                    COPY C:\*.DOC        A:
                                    DEL    C:\*.DOC


RENAME or REN  -  renames files

The RENAME or REN command is used to rename a file or a group of files. The file contents and the location of the renamed files remains the same.

Command Syntax:      REN    DRIVE:\PATH\ FILE1          FILE2


Example  1:     Rename a single file

                                    REN    C:\HELLO.BAT         MESSAGE.BAT

Example  2:     Rename a group of files to have a common file extension

                                    REN    A:\TEMP-DIR\*.BAT            *.BAK


DOSKEY  - recalls commands

The DOSKEY command is only available in DOS 5 and 6. Once the command is issued and the DOSKEY program installed it saves subsequent command lines typed in at the keyboard in an area, or buffer, of RAM; this in effect means that it 'remembers' previous command lines. The user can recall these lines with a few simple keysrokes instead of having to type them in again.

To start DOSKEY type
                                                DOSKEY       <return>

From this point on the command lines you input will be remembered.

You can then use the  ­ and  ¯ (or F8 ) keys to view the command lines and <return> to execute your choice.

You can edit a command line you have recalled by using the ¬ and ® keys to position yourself within the line and using the Insert key to switch between OverWriting and Inserting text before typing in your changes. You can also clear the current command line by pressing the ESC key.

Additionally

F7        Displays a numbered list of the commands DOSKEY has stored

F9        Allows you to selects a command by number

Alt+F7            Clears the buffer


TYPE  -  displays text files

The TYPE command is used to display the content of a text file on screen. (If the screen displays  garbled characters, with regular beeping  sounds, then it is likely that the file is a non text file.) TYPE merely displays a file; it does not allow you to edit/change it.

Command Syntax:      TYPE              DRIVE:\PATH\ FILE

Example:         Display the contents of a file called MESSAGE.BAT

                                    TYPE              MESSAGE.BAT


PRINT  - prints a text file

The PRINT command allows you to obtain a print-out of a text file. Printers are slow devices and are often shared by more than one computer. Obviously you do not want to have to wait until your file is physically printed before being able to continue using your machine. Therefore when you execute the PRINT command your file is added to a print queue - this is a list, stored in memory, of files waiting to be printed. This ‘queuing’ of a file by PRINT is very quick; much quicker than the actual printing of the file. Once the PRINT command has been executed DOS is free to execute other commands even though the relevant file might not yet have been printed. You can continue working and the file will be printed, in the background, when it reaches the top of the queue.

Command Syntax:      PRINT                        /SWITCHES               DRIVE:\PATH\ FILE

                                    Where SWITCHES are

                        T          -           Terminate printing i.e. remove all files from                                                               the print queue
                        C         -           Cancel printing of the specified file


Example  1:     Print two text files

                                    PRINT                   A:\TEMP-DIR\HELLO.BAK       MESSAGE.BAT


Example  2:     List the files in the Print Queue

                                    PRINT

Example  3:     Cancel the printing of MESSAGE.BAT

                                    PRINT                        /C                    MESSAGE.BAT

Example 4:      Empty the print queue

                                    PRINT                        /T


COPY   -  used to create a file

The COPY command can be used as a quick method of creating a small text file. The command line you use instructs DOS to copy all subsequent screen output (represented by CON:) to the file you specify, until you terminate this action and close the file by pressing Ctrl+Z (i.e. pressing the Ctrl key and before releasing it pressing the Z key) or the F6 function key.

This method of creating a file is very crude. Unlike EDIT or other editors it does not allow you to correct your mistakes as you are creating the file.

Command Syntax:      COPY             CON:              DRIVE:\PATH\ FILE

The best way to demonstrate this use of COPY is with an example.

Type in the following. Every thing you type after the COPY line will be stored in LONG-MSG.BAT until you press Ctrl+Z or F6. If you make a mistake while typing you can abort what you have done and return to the DOS prompt by pressing Ctrl+C (i.e. pressing the Ctrl and C keys in the manner indicated for Ctrl+Z above). Use your own name where it says your name.

                                    COPY             CON:              LONG-MSG.BAT
                                    @echo off
                                    echo.
                                    echo    GOOD DAY  your name
                                    echo.
                                    pause
                                    echo    YOU ARE USING
                                    ver

            Then type Ctrl+Z or F6


Now run this batch file which you have just created.


ATTRIB  -  sets file properties

ATTRIB enables you to assign files the properties, or attributes, of being Read Only (R), Hidden (H) and System (S) files. Each of these attributes (R, H, and S)  is assigned with  +  and cleared with  -

Command Syntax:      ATTRIB      +   attribute      DRIVE:\PATH\FILE(S)      /SWITCH
                                                         -   attribute

                                    Where attribute may be

R         -           read only file attribute   (file cannot be deleted or edited but can be listed with DIR and viewed and copied)
S          -           system file attribute   (file cannot be deleted or copied, nor is it visible with the DIR command but it can be edited)
H         -           hidden file attribute   (same properties as S)

A file may have more than one attribute

                                    SWITCH is

                        S          -           apply the command in all subdirectories of the path specified


Example  1:     Protect the MESSAGE.BAT file from being deleted or changed - i.e. making it Read Only

                                    ATTRIB          +R       MESSAGE.BAT

Try deleting or editing the file once you have added this attribute.

Example  2:     Remove the Read Only attribute from a file

                                    ATTRIB          -R        MESSAGE.BAT

Example  3:     Hide all the batch files in the current directory

                                    ATTRIB          +H       *.BAT

Use DIR to check the files have been hidden.

Example  4:     Make the files visible to DIR again

                                    ATTRIB          +H       *.BAT


Note, that although System and Hidden files cannot be seen using DIR, it is possible to find out what files have these attributes (and their names if you have forgotten them) by using   ATTRIB   on its own to view the attributes of all files in your directory.


FC  -  compares two files

This command can be useful for displaying the differences between two text files e.g. The current version of a file and an older version.

Command Syntax:  FC   /SWITCH   DRIVE1:\PATH1\FILE1    DRIVE2:\PATH2\FILE2

                                    SWITCH is
           
                        N         -           number the lines of the files

Example:
                                    FC       /N        MESSAGE.BAT        LONG-MSG.BAT



Redirection, Filters, Pipes

           Redirecting input and output  ( <, >, >> )
           Filters  e.g.  MORE,  SORT
           The Command Line Pipe  ( | )


Redirecting input and output  ( <, >, >> )

DOS assumes that the input to a command comes from the keyboard, and output goes to the monitor. However this flow can be redirected. Input can be read from a file rather than the keyboard, and output can be sent to a file or a printer instead of the monitor.

To read information from a file the  <  (less-than sign) must be used in the command line. To send information to a file or printer the  >  (greater-than sign) must be used.

Example  1:     Save the directory listing of C to a file

                                    DIR     C:        >          DIR-LIST      

If DIR-LIST already exist then its contents will be over written. Otherwise it is created containing the output of DIR.


The  >>  (double greater-than sign) is used to append information to an existing file rather than overwriting it.

Example  2:     Append a wide listing of the root of A and its subdirectories to DIR-LIST

                                    DIR     A: \      /W       /S         >>        DIR-LIST


To display the contents of DIR-LIST you could use TYPE. However there may too much information to fit onto one screen. Instead you can use the  <  redirector to read the contents of DIR-LIST into a DOS command which will display the information one page/screen at a time.

The command is MORE

Example  3:     Display the contents of DIR-LIST one screen at a time

                                    MORE                        <          DIR-LIST


Filters  e.g.  MORE,  SORT

A filter processes in some way the information input to it.

The MORE command is a filter that displays data input to it one screen at a time. As demonstrated in the last example it is often used with the  <  redirector.

Command Syntax:      MORE                        <          DRIVE:\PATH\ FILE

It is also commonly used with another redirector, the command line pipe (see next section).

Another filter is the SORT command which sorts a text file input to it into alphabetical order.

Example:
                                    SORT              <          DIR-LIST


The Command Line Pipe  ( | )

The pipe makes the output of one command become the input to another, allowing you to combine commands within a command line. To pipe commands place the  |  (broken vertical bar key on the keyboard) between the commands concerned. This causes all output generated on the left hand side of the bar to be sent to the right hand side for processing.

Command Syntax:      command-name   |   command-name

Example  1:     Display the output of the DIR command one screen at a time

                                                DIR   |   MORE


Pipes can also be used with the other redirection operators.

Example  2:     Pipe a listing of the files in the root of C to the SORT command and store the output of SORT in a file called ORDERED.LST

                        DIR     C:\       |           SORT              >          ORDERED.LST

Additionally you can have more then one pipe within a command line.

Example  3:
                        DIR     C:        |           SORT              |           MORE



Disk Manipulation

     FORMAT  -  formats a disk
     UNFORMAT  -  unformats a disk
     DISKCOPY  -  makes a copy of a diskette

FORMAT  -  formats a disk

A disk must be formatted for a particular operating system before it can be read from or written to by that operating system. DOS formatting creates a new root directory and file allocation table on the disk, it also destroys anything already on the disk. Therefore do not format a disk until you are sure there is nothing on the disk that you want to preserve.

You will not normally need to format a disk a second time (i.e. after your initial format of a blank disk). If you do reformat a disk, all existing data on it will be destroyed.

Command Syntax:      FORMAT       DRIVE           /SWITCHES

                                    Where SWITCHES are

                        S          -           create a DOS system/boot disk -  i.e. Format the disk and                                                    automatically install the DOS system files (IO.SYS,                                                                         MSDOS.SYS and COMMAND.COM) on it

                        F:x       -           where x is the floppy disk size
                                                i.e. one of 160, 180, 320, 360, 720, 1.2, 1.44, 2.88

The F switch is most commonly needed if formatting a DD (Double Density) disk in a HD (High Density) drive. Specifically, formatting a 3.5” 720 KB disk in a 3.5” 1.44 MB drive, e.g.

                        FORMAT       A:        /F:720

If you use the FORMAT command without switches on a 3.5” disk in a HD (1.44 MB) drive, DOS will attempt to format that disk to 1.44 MB even if it is a DD disk. This will result in a disk which is unreadable on DD drive machines. By using the F:720 switch the disk will be readable on both types of machine.


                        Other SWITCHES

            T:t        -           where t is the number of tracks per disk side
            N:s       -           where s is the number of sectors per track

Together these provide an alternative to the F:x switch for specifying the size of the disk being formatted, e.g.

                        FORMAT       A:        /T:80    /N:9
           
can be used to perform the same format as using F:720 above.


Remember -     a machine with a HD drive can read and format both HD and DD disks.
                        a machine with a DD drive can read and format only DD disks.


Examples using the FORMAT command -


Example  1:     Format a HD floppy disk in a HD drive

                                    FORMAT       A:

Example  2:     Format a disk as a DOS System disk

                                    FORMAT       A:        /S

Example  3:     Format a 3.5” DD 720 KB disk in a 3.5” HD 1.44 MB drive

                                    FORMAT       A:        /F:720
                                                                        /T:80    /N:9


SYS  -  makes a disk a System disk

If you already have a formatted disk which you want to be able to use as a System (or Boot) disk, you can install the 3 essential system files to it using this command.

Example:         Make the diskette in drive A a system disk by installing the system files on the hard disk to it

                                    SYS                 C:        A:

Note - that to make a disk a system disk you must either use the /S switch with the FORMAT command, or use the SYS command. Simply copying the system from one disk to another does not create a system disk.


UNFORMAT  -  unformats a disk

The UNFORMAT command is a limited safe guard introduced in DOS 5 to recover data from a disk which have been lost as a result of performing a FORMAT.

You should not really need to use this command if you are careful. It is good practice always to use the DIR command on a disk to see if it has already been used before trying to format it. If DIR displays information about files and directories or disk space then the disk is already DOS formatted. (However this simple test does not let you know if the disk has already been formatted but for a Macintosh computer.)

Note - Unformatting a disk only works if the UNFORMAT command is used before putting any new files on it.


Command Syntax:      UNFORMAT DRIVE:          /SWITCH

                                    Where SWITCH is

                        TEST   -           display only, non committal of data.
                                                This shows how UNFORMAT would attempt to
                                                recreate the information on the disk, but does not
                                                actually unformat the disk and do so.


Example  1:     Test to see how a disk would be recovered from a format

                                    UNFORMAT A:        /TEST

Example  2:     Actually recover from use of the FORMAT command

                                    UNFORMAT A:


DISKCOPY  -  makes a copy of a diskette

DISKCOPY makes an exact copy of one floppy disk (the source disk) on another (the destination or target disk). The original contents of the destination disk are destroyed. If the destination disk is unformatted DISKCOPY will format it. The disks should be of the same type (e.g. two 1.44 MB HD disks), however if the destination disk is of a different type from the source disk DISKCOPY will try  to format it to match the source diskette but this may not be possible.

Note - The XCOPY command (see later) is the best command to use when copying files between different types of disk (e.g. a 720 KB DD disk and a 1.44 MB HD disk), or when you want to preserves the original contents of the destination disk.


Command Syntax:      DISKCOPY               DRIVE1:                    DRIVE2:
                                                                        (source disk)                (destination disk)


Example  1:     Make a copy of a diskette using two identical drives. (The copy will be from the diskette in drive A to the diskette in drive B)

                                    DISKCOPY   A:        B:

If you only have one floppy disk drive, which is normal, you can still make an exact copy of a diskette. You specify drive A twice in the command line, start the copy with the source diskette in that drive, and swap it with the target diskette as directed during the copying operation until the copy is complete.

Example  2:     Make a copy of a diskette using one drive

                                    DISKCOPY   A:        A: