The TYPE command is used to display the contents of an ASCII text file on screen.
- To display text files one screen at a time, pipe the output from a TYPE command to MORE.
- TYPE does not support wildcard file specifications. If this is required, use COPY (see below).
- TYPE is primarily used:
- to display formatted text on the screen during the running of a batch file. This could be a menu leading up to a CHOICE command, or a warning/advice before proceeding with some operation. Although slightly slower to display than using ECHO, it is much easier to edit a text file than a series of ECHO statements.
- to feed the contents of a text file into a command using redirection.
- To modify a text file, search for a particular word, or move from one page to another and back, use Notepad in Windows95 or EDIT in Dos.
- TYPE is a special case of the COPY command - indeed:
is exactly equivalent (as far as I can see) to:
COPY filename CON > NUL
- To display the contents of HOLIDAY.MAR:
- If the file is too long to fit on a single screen:
TYPE holiday.mar | MORE
- To pipe the contents of GO.TXT to a DEL command requiring confirmation before deleting all files in a directory.
TYPE go.text | DEL *.*
If the first two characters of GO.TXT contain a "Y" or "y" followed by an [Enter], the files will be deleted. Anything else and the operation will be skipped.