Dos command create new file
To create a new file using the DOS command prompt, you can use the following commands:
type nul > filename.txt
- This command creates a new file namedfilename.txt
and assigns it a size of 0 bytes. Thetype nul
command outputs nothing to the file, and the> filename.txt
redirects the output to the file.echo. > filename.txt
- This command creates a new file namedfilename.txt
and writes a single newline character (\n
) to it.copy con filename.txt
- This command creates a new file namedfilename.txt
and opens it in the console editor. You can then type in the contents of the file and pressCtrl+Z
to save and exit the editor.fsutil file createnew filename.txt 0
- This command creates a new file namedfilename.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.