CON (short for Console) is an input device, not a command.

   Copy from the console to a new file:
      COPY CON filename.txt

   Type from the console to a new file:
      TYPE CON > Newfile.txt

   Type from the console to overwrite a file:
      TYPE CON >> Newfile.txt

After entering any of these commands, type in the text required, note there is no obvious prompt for this, then end the file by typing CTRL-Z, this will insert an EOF marker: ASCII 0x1a (SUB).

When using COPY the CTRL-Z can be placed anywhere, but when using TYPE it is important that the CTRL-Z is only entered at the beginning of a new line, otherwise it will just be saved into the file and you will have two EOF markers in the same file.

Most basic text editors will stop reading after the first EOF marker.

Some commands e.g. CLS, do not work as expected when redirected to CON and will output extra control characters.

To do this in Powershell use the following function:

function copycon {

con is a reserved filename.

A more advanced use of the console device is to redirect the console CON into FIND and then redirect the output from FIND into a file, this will make FIND discard any lines which do not contain the desired text. This can be useful for condensing large log files to return only the lines of interest.


C:\> FIND /i "Jones" <con > logfile.txt
zz Jones 2

C:\> TYPE logfile.txt
zz Jones 2

“One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be” ~ Fred Brooks (The Mythical Man-Month, 1975)


COPY - Copy one or more files to another location.
CHOICE - Accept keyboard input to a batch file.
Equivalent bash command (Linux): read - Read a line from standard input

Copyright © 1999-2019
Some rights reserved