Write a quick file without an editor or notepad from command line

This is an old trick you can use to quickly create ANY text file (.txt, .bat, .xml, etc..) from a command line.  This can be very useful if you want to create a quick batch file or test the ability to write a file to a folder.

From a command prompt type:

  1. copy con filename.xyz  (Substitute filename and xyz with the desired file name and extension – file.bat for example) and hit enter
  2. Start typing.. You are now writing line 1 of the file.  To get to line two, just hit enter.
  3. When you are done and want to “close” the file – hit ctrl+z, release and then hit enter.
  4. You have now written your file.


Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Bitnami banner