Dos command create new file

To create a new file using the DOS command prompt, you can use the following commands:

  1. type nul > filename.txt - This command creates a new file named filename.txt and assigns it a size of 0 bytes. The type nul command outputs nothing to the file, and the > filename.txt redirects the output to the file.
  2. echo. > filename.txt - This command creates a new file named filename.txt and writes a single newline character (\n) to it.
  3. copy con filename.txt - This command creates a new file named filename.txt and opens it in the console editor. You can then type in the contents of the file and press Ctrl+Z to save and exit the editor.
  4. fsutil file createnew filename.txt 0 - This command creates a new file named filename.txt and sets its size to 0 bytes.

Note: The fsutil command is only available in Windows XP and later versions.

Example:

C:\>type nul > newfile.txt

This command creates a new file named newfile.txt and assigns it a size of 0 bytes.

Alternatively, you can use the echo command to create a new file with some initial content:

C:\>echo. > newfile.txt

This command creates a new file named newfile.txt and writes a single newline character (\n) to it.

You can also use the copy command to create a new file and open it in the console editor:

C:\>copy con newfile.txt

This command creates a new file named newfile.txt and opens it in the console editor. You can then type in the contents of the file and press Ctrl+Z to save and exit the editor.