CMD Master
Back to Blog
UpdatedArnošt Havelka

How to Create a Text File in CMD with copy con

Create a small text or batch file in CMD without Notepad: start copy con, enter each line, then press Ctrl+Z and Enter to save.

Start Interactive Lesson
How to Create a Text File in CMD with copy con

If you searched copy con command, you want a file in Command Prompt without opening Notepad. copy con filename copies from the console (your keyboard) into that file. It is the same copy command documented on Microsoft Learn: copy, with con as the source. Walk through it in the copy con lesson.

Try the command

Create a quick note!

Build the command
copyconnote.txt
F6 or Ctrl+ZPress this after typing your text to save the file.
EnterPress Enter to move to a new line while typing.
COPY CON mode: note.txt
C:\Users\Student>copy con note.txt
Enter adds a line. Save file finishes. Ctrl+Z saves; Ctrl+C cancels.

What copy con does

con is the console device. copy con note.txt means: take everything you type and write it to note.txt. Any extension works (.txt, .bat, .cmd). If the file already exists, copy asks before overwrite unless you pass /y.

This is a one-shot stream. You cannot move the cursor up to fix an earlier line. For a real editor, use Notepad or type to read a file you already saved.

How to create and save the file

  1. Type copy con note.txt and press Enter.
  2. Type each line. Enter starts a new line.
  3. When you are done, press Ctrl+Z or F6. You should see ^Z.
  4. Press Enter. cmd prints 1 file(s) copied.
Terminal
C:\Users\Student>copy con hello.bat

Common mistake

Pressing Enter and expecting the file to save. Enter only ends the current line. The end-of-file marker is Ctrl+Z (or F6), then Enter. Ctrl+C cancels and does not save.

copy con also replaces the file. It does not append. To add text, copy to a new name or use a different tool.

copy con compared with echo

copy con is useful when you need several lines and want to type them interactively. For one short line, echo is usually easier:

echo Hello>note.txt

The redirection operator writes the line immediately, while copy con keeps accepting input until you send the end-of-file marker. Choose the method that matches the amount of text rather than using copy con as a general-purpose editor.

FAQ

How do I create a text file in CMD? copy con filename.txt, type content, then Ctrl+Z and Enter.

How do I save with copy con? Ctrl+Z or F6, then Enter. Look for 1 file(s) copied.

What key ends copy con? Ctrl+Z or F6, not Ctrl+S.

Can the file have another extension? Yes. copy con run.bat is a common trick for a tiny script.

How do I append instead of replace? copy con cannot append. Use another command or editor.

To copy an existing file to a new name, use copy, not copy con.

Knowledge Check

1 / 3

What does con stand for in copy con?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Fc Command

Compare files and find differences instantly.