Windows and OS training

YBET   Hardware IT training

3. Hard disk and floppy in DOS

1. Diskettes and hard drives - 2. Directory commands - 3. Manipulation of files - 4. Commands for text files

A file is a set of information grouped under a single name. This can be an address list, a set of recipes from kitchens or even an executable program.

On DOS, a file that is stored on the disk hard (or a floppy disk) is designated by a name consisting of 1 to 8 digital - alphanumeric characters or special characters: $ & # @ ! % () - < > _

The file name is followed by an extension of 3-character maximum, spaces are prohibited between 2 letters. This extension is used to determine the file type.

DOS does not distinguish between uppercase and lowercase letters. Accented characters are prohibited.



DOS implicitly recognizes some extensions:

Others are used by convention:

Doc and .txt files are often used on the installation disks, and file (English) or (french) such as documentation or solution during the installation. These are text files.

1. Hard disks and floppy disks

DOS automatically recognizes the hard drives and floppy disk drives if they are detected by the BIOS. A CD-Rom drive requires additional drivers. A hard disk or floppy disk must first be prepared using the DOS Format command.

Capacities are expressed in Byte. For 1024 bytes, known as Kilo (KB or KB), for 1024 kilograms, one speaks of Mega (MB or MB).

Floppy drives are the letters "A:" and "B:". The first partition of the hard drive is as "C:", the other partitions are the following letters. To switch from one drive to another, simply type the letter followed by 2 points.

The organization of the data on the hard drive (to a lesser extent the floppy) is done by directories and subdirectories. These directories can gather the data in specific boxes. When you read data on a hard disk, you start by the ROOT, this is the top directory of the disk. It contains data and directories. The command to display the files in the current directory is DIR

Example: the C: disk contains:

2. Commands directory

Without going into the details of these commands, we will move one directory to another, create and delete, view the content.

1.1 DIR (internal control).

>DIR displays the contents (files and directories) of the current directory

Example, we are in the main directory of the hard drive C: (that shows us the prompt DOS displaying c:\>).

c:\>dir <Enter>

Directory of C:\

COMMAND COM      47845     09/04/91  5:00

AUTOEXEC BAT            336    08/09/92   22:02

CONFIG SYS                 670   08/09/92   20:19

DOS             <DIR>               07/09/92   15:44

UTILS           <DIR>               07/09/92 16:14

5 file (s) 48851 bytes

30599168 bytes free

The information displayed is for the file: the name and the extension, the size in Byte (octet), the date and time of change. For directories, type (<DIR>) and the date of modification.

When the number of files to display is too large, part of the information scrolls without being visible to the user. Two options are available:

> DIR /P: displays the contents of the page directory. Press any key to display the next page
> DIR /W: displays the contents of the directory, but only the names and extensions in columns. Win 2000, this command is replaced by DIR/D

the space between the command and the optional characters can be omitted.

It is also possible to only display files that meet certain criteria using masking and replacement characters.

? replaces a single character
* replaces a set of characters.


c :>DIR *.sys displays only files with extension sys.

c :>DIR conf*. * displays all files whose name begins with conf, regardless of the extension.

c :> DIR *.?at displays all files that have the extension terminated at, for example bat files.

2.2 CHDIR or CD in abbr.: internal command

c:>CD directory <RETURN> or CHDIR directory <RETURN> to move in the indicated directory

Example: you are in the main directory of C: (the root). You want to move to the sub-directory DOS, type: c :> DOS 

CD .. to up one level of directory
CD\ returns to the main directory (root) whatever the current subdirectory
CD\ <sub-directory1> \ <sub-directory2> positions the cursor on the <sub-directory2> Directory, which is included in the <sub-directory1> himself included in the current directory.

In summary:

2.3 MKDIR (MD for short), internal command.

c:>MKDIR <sub-directory> or MD <sub-directory>: creates a subdirectory in the current directory according to the specified name

Example: c :> MD nothing creates the directory nothing in the root of C:

2.4 RMDIR (RD for short), internal command.

c:>RMDIR <subdirectory> or RD <subdirectory>: deletes the directory if it is empty. (Remove Dir)

If the folder to delete is not empty, the command is denied. DOS displays a message to notify.

2.5 Tree: external control

>TREE: displays all directories in the current directory
>TREE/F: displays the directories and files in these directories
>TREE /F |more: displays the directories and their content by page

The display is done in the form of tree

3. Manipulations files

Are included in this part the commands to run a program, delete, move, rename files. Create a file in dos through the use of a program. Backups on disks commands are included in a separate chapter.

3.1 Execution.

c:>Program1: executes the program whose name is Program1. The extension is not necessary.

DOS supports 3 kinds of executable files directly following the extension:

If the software is not in the current directory, we can start typing: name_disk:\directory\subdirectory\program. For example >c:\dos\tree

The Path that will be seen later command do not type the location for certain locations.

3.2 Copy: internal control

 >COPY file1 file2: copy file1 to a file whose name is File2

The change of location is accepted, as well as wildcards? and *. Unlike Windows, DOS will overwrite the destination file already exists without confirmation.


> COPY autoexec.bat autoexec.sav

>COPY *.bat * .sav: copy all the file with a .bat extension to same name with the extension .sav files in the current directory.

>COPY c:\DOS\*.exe A:\*.exe: copies all files executable .exe from the DOS directory to the floppy disk.

In some cases, the . as:

>c:\DOS>COPY a:\rien.* will copy all files whose name is rien to current directory

The use of wildcard characters can sometimes cause a few problems.

c :> COPY c:\*.exe a:\rien.* is false. It copies all .exe files to a single file rien.exe. As the COPY command overwrites the destination file, only the last file will be copied.

The XCOPY command also copies directories

3.3 RENAME (REN for short): internal control

c:\>rename file1 file2: renames the File1 to file2

Permission of replacements characters is allowed. All the principles of the command COPY shall also apply. If the destination file already exists, it is overwritten.

3.4. DEL or ERASE: internal command

c:\>DEL file1: deletes the specified file

Wildcards are permitted but not desirable. The DEL and ERASE commands only offer no confirmation. 

3.5 UNDELETE: external (from DOS 5.0)

Note that this command is not as powerful as the Windows Recycle Bin. The location of a deleted file is left free for other files. It must be performed immediately after the deletion.

c:\>UNDELET file 1: recover files erased by a DEL or ERASE command under certain conditions

The use of wildcards ? and * are authorized.

3.6 COMP: external command

c:\>COMP file1 file2: compares the 2 files and displays the first 10 errors.

3.7 XCOPY: external command

This command is similar to the COPY command but also transfers the files included in the directories. It is still used in batch files.

c:\>XCOPY source [destination]: copy the source folder and its subfolder to the folder of destination.
  • By default, the directory is destination is the current directory
  • /A: only the files not backed up, does not set to archive bit to 1
  • /M: only files not backed up, puts the bit of archive 1
  • /P: request before you create new folders
  • /V: Verify copied files
  • /H: also copies hidden files
  • /Y: no longer prompts for confirmation to overwrite an existing file

This command uses different options that differ from one version to the other, especially for versions 2000 and XP. I see that the main.

4. Command for text files

Are included here some DOS commands specific for text files.

4.1. TYPE: internal command

c:\>TYPE file1: displays the contents of an ASCI file to the screen

This command displays the contents of a text file on the screen, including the extension TXT, BAT, ...

4.2 PRINT: external

c:\>PRINT file1: prints the text

On Witch device file? LPT1 or PRN, COM1...

This command to print an ASCII (text) file. If the port is not specified, the command ask it (see communication ports). If the option is omitted in the following command, it takes the device before. >Print fichier1 LPT1 and >print fichier1 PRN give the same result.

Wildcards (? and *) are permitted, but may cause problems with the printing of the executable .com or .exe files.

c:\>PRINT Displays the files printing
c:\>PRINT /T: removes files waiting list printing 

Next -> Systems commands

<- Files and directory manipulation

Hardware PC training - Hardware 2 course: Network, servers and communication.