How to Create a File in CMD
Last Updated : 07 Apr, 2025
We all know that one can easily create files using GUI options, but what if you can use a faster way to create files through the command-line interface? This is not a necessary but useful skill for anyone working with Windows. Whether you're automating tasks, working on scripts, or preferring using the command prompt, knowing how to create a file in CMD can be incredibly useful.
This article will walk you through the steps to create a file using CMD, ensuring that you can efficiently manage your files directly from the command prompt.
Methods to Create A File on Windows using CMD
To start a new file on Windows using CMD, the following guidelines should be used. Let us start with the basic Echo Command.
Note: All of these methods should be executed in any certain directory. Otherwise, the operations will not completed. Use the CD Windows Command to enter into any certain Windows directory.
Method 1: Create Text File Using ECHO in Command Prompt
Step 1: Open CMD
- To create a file using CMD open CMD press Win + R key on your keyboard and type CMD to open CMD.
Step 2: Type ECHO Command
- Once the CMD opens execute the following command.
This method will directly save the file to the directory mentioned earlier. You have to put some text for it.
Command: echo. > Rapture.txt
Echo commandCongratulation! The New Text File on Windows is created using the Command Prompt with one simple command.
Method 2: COPY CON Command to Create a New File
Step 1: Use copy con in CMD
- You need to type "copy con" followed by the name of the file you wish to overwrite and once you're done press the CTRL + Z to end the operation & the file will be directly saved to the directory.
Let's understand this with the below-mentioned example where the file name = 'Rapture'
Command: copy con Rapture.txt
copy con commandHooray! We have successfully created a Text File on Command Prompt on Windows in a certain directory without opening it.
Method 3: Quick Guide to Create a File in CMD - NOTEPAD Command
The following command can be used to open any Text File. Either, you can open the New File with any predefined name or any existing one in the certain directory. It will open the Notepad Windows Application, make changes there & press CTRL + S to save it.
Command: notepad Rapture.txt
notepad commandMethod 4: 'fsutil' Command to create a "specific" size file
The following command can be used to create a file in CMD for any specific size. Once you create the file, you do perform tasks accordingly.
For example: Let's create a file of size 10 bytes with the filename as 'Rapture'
Command: fsutil file createnew Rapture.txt 10
'fsutil' CommandMethod 5: "type nul" Command to create a new File
The type nul command in cmd can be used to create a new file wherein the "type nul" denotes to do nothing and starts with an empty file. Let's understand this with an example below where the filename is 'Rapture'.
Command: type nul >Rapture.txt
type null commandConclusion
Mastering the ability to create a file in CMD is an essential part of becoming proficient with the command line in Windows. By using the right CMD command to create a file, you can streamline your workflow and perform tasks more efficiently. Whether you’re creating simple text files or working on more complex scripts, understanding how to make a file in CMD gives you greater control over your system.
Also Read
Similar Reads
How to Create a Batch File in Windows?
A batch file is a straightforward text document in any version of Windows with a set of instructions meant to be run by Windows' command-line interpreter (CMD) by maintaining all the functions. Batch files are a great tool for streamlining internally configured processes, automating tedious jobs, an
5 min read
How to Create an Empty File in Linux | Touch Command
The touch command is a standard command used in the UNIX/Linux operating system which is used to create, change and modify the timestamps of a file. Basically, there are two different commands to create a file in the Linux system which are as follows: touch command: It is used to create a file witho
8 min read
How to Create an Unnamed file in Windows?
There is curiosity hidden inside everyone. So when it comes to computers we all try to know why this is happening, what will happen if I run this software, what will happen if I delete some of Windows files and etc. We also sometimes try to make a file without a name in Windows and fail and then, fi
2 min read
How to Delete a File or Folder Using CMD?
While working on Windows devices, we used to work on Windows File Explorer for working with files. On File Explorer of Windows, the creation of new files as well as deleting old ones is one of the easiest processes. However, if your File Explorer is not responding, then the process to Delete Folder
5 min read
Create a Temporary File in Java
In Java, we can create a temporary file using an existing method known as File.createTempFile() method which creates a new empty file on the specified directory. The createTempFile() function creates a temporary file in a given directory (if the directory is not mentioned then a default directory is
4 min read
How to List all Files in a Directory using CMD
Struggling to find or organize files buried in folders on your Windows PC? While File Explorer offers a visual way to browse, the Command Prompt (CMD) provides a faster, more powerful method to list, sort, and manage files, especially when dealing with large directories or automating tasks. In this
5 min read
How to create and write to a txt file using VBA
This VBA Program reads an Excel Range (Sales Data) and writes to a Text file (Sales.txt). This helps in faster copying of data to a text file as VBA coding enables automated copying. Let us learn how to do it in a few easy steps: Excel VBA Write Text FileIn the realm of Excel VBA, the power to inter
5 min read
How to Append Data to a File in MATLAB?
Appending data to a text file means adding data to a file that already exists in the storage. print() function is used to write/append data to a file in MATLAB. It writes formatted text to a file based on the format string provided to it. The format of the output/input is determined by the formattin
4 min read
How to Create a Text File Using the Command Line in Linux
The Linux command line is a powerful tool that allows you to manage your system with precision and speed. One of the most common tasks is creating a text file, which can be achieved using several commands and methods. Here we will learn some quick ways to create a text file from the Linux Command Li
6 min read
How to Create a File in VSCode using Terminal?
In a few cases touch or new-item or any other base keywords may not be used to create a file in vs code due to the absence of extensions, but using the following approach you can create and code any type of file with ease. In this article, you will learn about how to create a file with any file type
3 min read