< Previous | Contents (GEM) | Contents (DOS+) | Next >

4  FILE HANDLING AND PRINTING


4.1 Introduction

DOS Plus offers powerful file handling features: you can use DOS Plus for all the things you might want to do such as copying files, or combining several files into one, as well as erasing files when you don't need them any more, or renaming them as your filing system structure develops. You can also 'print' text files on the console screen or on a printer.

Files are usually created by applications programs rather than by DOS Plus itself. We will see later how you can create files with DOS Plus, using either the COPY or ED commands. In this chapter, however, we will concentrate on using DOS Plus in file management with existing files.

4.2 Copying files

The COPY command enables you to copy a file onto another disc, drive or directory. The original file remains intact.

Suppose you want a copy of the file filename.ext on another disc. Put the original disc (the source disc) into one drive, say drive A, and then type:

A>COPY a:filename.ext b: RETURN

The screen will then prompt you to insert a disc into drive B (because you specified b: in the command as the destination). COPY works equally well with systems containing one or two floppy disc drives, or a Winchester hard disc drive; the Winchester is typically referred to as drive C.

COPY differs from the copying option found in the DISC command. That option is designed for producing backup copies of entire discs. Use COPY when you want to process single files or groups of files:

COPY is a powerful DOS Plus command which can do more than we have described here. (See section 4.5 for a use of COPY in combining files, and section 5.2 for creating files using COPY CON:). COPY can be used to move copies of files to or from a printer, keyboard, console or auxiliary device such as a modem. For information on these functions, see the full DOS Plus manual.

You can use wildcard characters to copy groups of files. For example, suppose you have many files on a hard disc and you want to take a disc of all the letters sent to Belgium (which you have identified by the blg extension), type:

A>COPY c:*.blg a: RETURN

The * character matches all letters in a filename, so *.blg identifies and copies all the files with the blg extension (see next section for full details.)

4.3 Using Wildcards

If you are performing the same operation on a number of similar files, DOS Plus provides a shortcut that will save you typing in a string of similar commands. "Wildcard" characters can replace some or all of the characters of the filenames specified in most commands.

Two wildcards are provided in DOS Plus:

These characters can be used separately or together to create ambiguous file specifications.

For example, suppose you have the following files in a directory on drive A:

reports1.jja
reports2.jja
reports3.jja
memo.jja
address.jja
reports1.amk
reports2.amk
amemo.amk
bmemo.amk
report
report10.jja

You could use wildcards in several ways:

A>DIR reports?.* RETURN

Lists all the files that begin with the letters "REPORTS", followed by one character and have any (or no) file extension. That is, it will list reports1.jja, reports2.jja, reports3.jja, reports1.amk and reports2.amk. It would miss report10.jja and report. You would need report??.* to catch those.

A>COPY a:?memo.amk b: RETURN

Copies amemo.amk and bmemo.amk from drive A onto drive B.

A>DIR r*.jja RETURN

or

A>DIR rep?????.jja RETURN

or

A>DIR rep*.?j? RETURN

or several other combinations would all list reports1.jja, reports2.jja, reports3.jja and report10.jja, but not reports1.amk or reports2.amk

Remember that wildcards can only be used in filenames and file extensions, not as drive specifiers or in typing DOS Plus command names DOS Plus only uses wildcards as a pattern when it is searching a disc directory, so a few commands do not permit wildcard characters.

4.4 Renaming files

The RENAME command simply changes a file's name. You can change the filename, the filename extension, or both.

To rename a file, inset the disc that contains the file you want to rename and type, for example:

A>RENAME oldfile.ext newfile.ext RETURN

This will rename the file oldfile.ext as newfile.ext. The renamed file stays in the same drive (and directory), which in this example is drive A.

Notes

    1    You can abbreviate RENAME to REN
 
  2  

You can rename a file that is in a different drive by adding the drive letter before the old file name, for example:

     

A>REN b:oldfile.ext newfile.ext RETURN
 

  3  

RENAME permits wildcards – see section 4.2 above – so that you can rename a series of files. For example:

      A>REN b:*.tex *.bak RETURN

This will rename all your tex files on drive B as bak files.

4.5 Combining files

You can use COPY to combine several small files into a larger one.

Put into drive A the disc containing the files you want to combine and type

A>COPY file1.ext+file2.ext newfile.ext RETURN

This copies the contents of file1.ext and file2.ext into a new file called newfile.ext on the same drive. Note the space before newfile.ext that signals the end of the source file list. You can also copy to or from a different drive by adding drive letters. For example:

A>COPY filel.ext+file2.ext b:newfile.ext RETURN

copies from the default drive onto drive B.

The original file1.ext and file2.ext are left intact (you can erase them if you want to by using the ERAQ command as described below.)

4.6 Erasing Files

The ERAQ command erases files from a disc. Use this command carefully, because once a file is erased it is lost completely.

To erase a file, insert into drive A the disc containing the file you want to erase and type

A>ERAQ filename.ext RETURN

This produces the message:

filename.ext (Y/N)?

Check the filename to make sure it is correct, and they type y to erase the file (or any other key to leave it untouched).

You can delete several files in a series by using wildcards. This saves you typing in a long list of similar commands. For example if you wanted to delete all the backup files from a disc you could enter ERAQ*.bak. Use ERAQ in this way if you want to keep one or two bak files but delete the rest.

There is another command, ERA, that works in a very similar way to ERAQ except that ERA deletes the files without questioning you. ERAQ is safer because it gives you the chance to check before it's too late.

4.7 Displaying files

TYPE displays the contents of a specified text file on your screen, or at the printer, or both.

To use TYPE, insert, into disc A for example, the disc containing the file you want to display and type:

A>TYPE filename.ext RETURN

This scrolls the text of the file up the screen. Press CTRL and S to interrupt the listing and CTRL and Q to resume.

If you want to display a screenful of text at a time, type /P:

A>TYPE filename.ext /p RETURN

To list the file at a printer as well as on the screen, type CTRL and P before entering the TYPE command. To stop the printer at any time, type a second CTRL and P. The listing will continue on the screen.

< Previous | Contents (GEM) | Contents (DOS+) | Next >

About the Master 512 | Bibliography