Cretate new file with cmd
To create a new file using the Command Prompt (Cmd) in Windows, you can use the following command:
type nul > filename.txt
Replace filename.txt
with the name you want to give to your new file.
Here's how it works:
type
is a command that outputs the contents of a file to the screen.nul
is a special file that represents the null device, which means it doesn't output anything.- The
>
symbol is used to redirect the output of thetype
command to a new file.
When you run this command, it will create a new file with the specified name and contents (which will be empty, since we're redirecting the output of nul
).
Alternatively, you can use the echo
command to create a new file with some initial content:
echo. > filename.txt
This will create a new file with a single newline character (\n
) as its contents.
Note: If you want to create a file in a specific directory, you'll need to navigate to that directory using the cd
command before creating the file. For example:
cd C:\Users\username\Documents
type nul > newfile.txt
This will create a new file called newfile.txt
in the Documents
directory.