Dealing with Files
Microcomputer/DOS Tutorial


Computer Studying

Navigation
{NavForms}

Virus Tutorial Map
Tutorial Map

When using a computer you almost always have to do something to manage files. There are several DOS commands designed to help you.

Erasing Files

Files you no longer need should be deleted from your disk to make room for more current files. Use the ERASE (DELete) command for this:

ERASE d:FILENAME.ext

or

DEL d:FILENAME.ext

Be careful, typographic errors in this command can bring disaster!

You are allowed to delete all files on a disk with the wildcard * (ERASE *.*), but DOS will question you.

Recovery BEFORE writing anything else to disk is possible. An UNDELETE utility started shipping with DOS 5.0. Before that commercial utilities were available.

Renaming Files

For whatever reason, you may need to change the name of a file on your disk. (Usually this is the case when you want to change a backup file to another name in order to return it to active status.)

Use this format:

REName d:OLDNAME.ext NEWNAME.ext

Wildcards are allowed, but can cause trouble if you are not careful.

The rename command will give you an error message if NEWNAME exists.

Copying Files

The COPY command is a very powerful command within DOS. With it you can create duplicates of individual files, join several files into one, and even use your computer like a simple typewriter by "copying" from the device named CON: to the device named PRN (inefficient, but OK for short notes).

Copying one file to another (copies from filename1 to filename2):

COPY d1:FILENAME1.ext d2:filename2.ext/v

/v option verifies the copy as it takes place. This adds confidence at the price of slower operation.

There are other options not shown here. Wildcards are allowed.

For example,

C:\>COPY ADDRS.LST B: Copies the single file ADDRS.LST from C: to B:.

C:\>COPY *.* B:/V Copies all files on C: to the disk in B: and verifies the information is it is being written.

C:\>COPY ADDRS.LST Yields an error message. Can't copy a file to itself.

C:\>COPY B:*.* Copies all files from drive B: to drive C:. (If a destination is not specified, the default drive and directory is used.)

Copy can also be used to concatenate (join) several files by using the following form:

COPY d1:FILENAME1.ext+d2:FILENAME2.ext+... d0:filename0.ext/v

The options are the same as the previous version of the copy command.

All specified filenames (#1, #2, etc.) will be copied and joined into filename0. If no filename0 is specified, the first source file named will be used.

Wildcards are dangerous with this command.

Example:

Contents of FILE1: This is file number one
Contents of FILE2: This is file number two

C:\>COPY FILE1+FILE2 FILE3

Contents of FILE3: This is file number oneThis is file number two

The COPY command can be used to create text files by copying from device CON: to a file. The procedure is outlined in the text of the example below.

C:\>COPY CON: TEXTFILE

This is the text to go into the text file being created.
Each line is typed to the screen and it is being saved into
a buffer for later transfer to the file TEXTFILE. Each line may
be corrected as it is typed, but cannot be changed after it is
terminated by the carriage return. Also, if you happen to type
beyond column 80 on the screen, you cannot correct anything on the
line above. Each line must be terminated by a carriage return
(the enter key). You signal you are finished by typing a
Control-Z, the symbol for end-of-file, followed by Return.
^Z

1 File(s) copied

XCOPY

For copying multiple files the XCOPY command can be a powerful ally. As its name implies, the command performs extended copies.

Its format (with only often-used options) is shown here:

XCOPY d1:PATH1 d2:path2 /a /m /s /v

Like the COPY command, XCOPY can take a single drive/path designator in which case files from that destination will be copied into the current directory. Some options:

/A Copy only files with archive bit set; do not reset archive bit.
/M Copy only files with archive bit set; reset archive bit.
/S Copy subdirectories as well unless they are empty.
/V Verify copied files as they are written.

You can copy an entire hard disk to another disk with a single command:

XCOPY C: D: /S

The contents of drive C: will be copied to drive D: a file at a time, with the subdirectory structure intact.

You can use the same technique to back up a hard disk to a removable disk (e.g., Bernoulli or other removable media - don't use floppies). Note the /M option above. When DOS writes a file to the disk it sets an archive bit in the disk directory to indicate the file has been somehow changed (it's possible to write a file and not change it but DOS just assumes changes were made). The /M option for XCOPY can take advantage of this.

To proceed:

1) Make a full backup first.

Use the ~ATTRIB~ command to set all archive bits to ON:

C:\>ATTRIB +A *.* /S

Use XCOPY to copy all files and directories, turning all archive bits OFF in the process (assumes removable media is G:):

C:\>XCOPY C:\ G: /M /S

2) On a regular basis use the XCOPY command to perform an incremental backup:

C:\>XCOPY C:\ G: /M /S

The backup on drive G: will be an image of the file and directory structure on drive C:. The incremental backup makes certain the image is current.

Periodically, in order to purge deleted files from the backup you should start over at #1 above and a clean backup disk.

Typing a File

Any text file saved in ASCII character format can be easily seen on your video display. Use the type command:

TYPE d:FILENAME.ext

All characters in the file will be displayed on the screen, including any control characters, sometimes resulting in interesting displays.

Any control-I characters found will be interpreted as a tab, and spaces will be added to get the cursor over to the next 8-character boundary; some output may appear as tables. Control-Z will cause output to stop.

Attempting to TYPE a .COM or .EXE file will result in garbage on the screen, and should generally be avoided.

Keep Reading Subdirectory Introduction


{NavBar}
Home | Products | Definitions | Newsletter | Virus Tutorial | Contact


FILExt is proudly hosted by DewaHost.com - a fast and reliable host for everyone!
DewaHost offers premium Web hosting starting from $8.95/month and a high speed file hosting service FileBurst!

Please use the contact form for questions or comments about this web site.
Copyright © 2001 Computer Knowledge, All Rights Reserved
Pray the Rosary for peace.