How to create a file in MS-DOS

Windows command line (DOS)Below are all the different examples of how a file can be created in MS-DOS or from the Windows command line.

Edit command
Copy con command
Start command
Listing the file after created

With the edit command

Note: 64-bit versions of Windows do not include the edit command. Instead of using edit, use the start command mentioned below.

edit myfile.txt <press enter>

If available, this should open the edit editor. Once you have typed the information for the file myfile.txt, click File and choose exit. If you do not have a mouse, see the edit command page. 

When clicking exit, the computer will prompt you if you want to save the file, click Yes and the file will be created.

With copy con command

copy con myfile.txt <press enter>

When typing the above line the cursor moves down one line to a blank line. Create the file line by line. Once you are ready to create the file press enter to get to a blank line and then press and hold Ctrl and press Z then let go of both buttons. This returns a ^Z. Once this has been entered press enter to save and exit the file. 

With the start command

start notepad myfile.txt <press enter>

The Windows Notepad and any text editor can also be started to create a file from the command line. Entering the above command would use the start command to start Notepad and create the myfile.txt. Once the file was saved in notepad that file would be created in the same directory as the command.

How to list the file once created

After the file has been created using any of the above methods you can list the file using the dir command.

Additional information