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 LessonIf 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.
Create a quick note!
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
- Type
copy con note.txtand press Enter. - Type each line. Enter starts a new line.
- When you are done, press Ctrl+Z or F6. You should see
^Z. - Press Enter. cmd prints
1 file(s) copied.
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 / 3What does con stand for in copy con?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Compare files and find differences instantly.