We will elaborate on the ways to create an empty file through the Windows Command Line in this blog:
So, let’s get started!
Use Command Prompt to Create Empty File on Windows
To create an empty file using the command line on Windows, you can utilize the below-listed commands:
We will discuss each of them one by one.
Method 1: Use “cd.” Command to Create Empty File
Check out the method provided below to learn how to create an empty file using the “cd.” command.
Step 1: Open Command Prompt
First, search for “Command Prompt” in the “Startup” menu and open Command Prompt as administrator:
Step 2: Open Directory
In the next step, specify the path in the “cd” command to open the preferred directory where you want to create and save an empty file:
Step 3: Create an Empty File Using “cd.” Command
Utilize the “cd. ” command and redirect “>” its output to an empty file. After creating the file, use the “dir” command the verify the existence of the created empty file:
Method 2: Create an Empty File Using “echo.” Command
To create the empty file, run the “echo. >” command and redirect “>” the output to the new empty file. Then validate the performed operation with the “dir” command:
Method 3: Create Empty File Using “call” Command
Empty file can also be created through the “call” command. For this purpose, follow the provided command:
Method 4: Create Empty File Using “break” Command
To create an empty file on Windows Command Prompt, the “break” command can also be used. After that, execute the “dir” command to list all files and confirm whether the empty file is created or not:
Method 5: Create Empty File Using “copy nul” Command
To create the empty file on Windows using “copy nul”, write out the below-given command:
After creating the file, utilize the “dir” command to view a list of files for the confirmation purpose:
Method 6: Create Empty File Using “type nul” Command
In order to create the empty file on Windows using the command line, you can use the “type nul” command on Command Prompt as shown below:
Then, utilize “dir” command to view a list of files to confirm whether the file is created or not:
We have successfully demonstrated the methods used to create an empty file in Windows Command Prompt.
Use PowerShell to Create Empty File on Windows
In order to create an empty file on Windows, you can use the “New-Item” command on PowerShell. Follow the below-given instructions to create empty file.
Step 1: Open PowerShell
Firstly, press “Window+X” to access the Power User menu. Then, open the Windows PowerShell as administrator:
Step 2: Create New Empty File on a Specific Location
Create an empty file using the “New-Item” command and add the path where the file will be saved. The last portion of the path will be considered as file name:
Or simply execute the given command for creating an empty file in the current directory:
From the below-given output, you can see that we have successfully created the “samplefile1.txt” empty file:
We have effectively compiled the solutions to create an empty file on Windows.
To create an empty file on the Windows Command line, you can utilize Command Prompt or PowerShell. On Command Prompt, many commands are available to create a new file or empty file, such as “cd.”, “copy nul”, ”break”, “echo.”, “type nul”, and “call”. In Windows PowerShell, the “New-Item” command can be executed for the same purpose. We have illustrated the methods to create empty files on the Windows command line.