How to Create File in CMD? (cmd create file)

While it's common to create files using the graphical interface, there's a quicker and more efficient method—using the command-line. Though not essential, it's a handy skill for anyone working with Windows. Whether you're scripting, automating tasks, or simply prefer using the command prompt, being able to create file in windows cmd can greatly enhance your productivity and workflow.

To create file in CMD, you can efficiently manage your computer’s file system, enabling you to quickly create files and folders without navigating through multiple menus or dialog boxes. Whether you need to create a file or folder, the CMD commands are here to assist you. In this post, we'll guide you through the process of using CMD commands to create files and folders. If you're curious about how to create a file in CMD on Windows 11, keep reading.

Explore Key Windows Commands

Unlock the full potential of your Windows system! Click here to explore essential Windows commands that can streamline your daily tasks. Whether you're new to Windows or a seasoned user, our detailed guide will help you navigate the OS more efficiently. 

Learn hidden features, discover time-saving shortcuts, and gain expert tips. Begin mastering Windows today!

How to Create File Using CMD? (Step by Step Guide: CMD Create File)

Windows Command Prompt (CMD) provides a quick and efficient way to create files and folders, making it a valuable tool for automation, scripting, and bulk file creation. This eliminates the need for graphical interfaces, helping you save time and increase productivity. In this guide, we’ll show you how to use CMD create files on Windows 10:

Step 1: Open the Start menu.

Step 2: In the search bar, type "Cmd".

how to create file in cmd? (cmd create file)

Step 3: Press Enter to open the Command Prompt.

Step 4: Type dir and press Enter. This will list the contents of the current directory, giving you an overview of the files and folders.

how to create file in cmd? (cmd create file)

Step 5: Type cd Downloads and press Enter to navigate to your Downloads.

how to create file in cmd? (cmd create file)

Step 6: Type mkdir test and press Enter. This will create a folder named "test" on your Desktop.

Step 7: Minimize the Command Prompt window for now.

Step 8: Go to your Downloads to verify the creation of the "test" folder.

Step 9: Return to the Command Prompt.

Step 10: Type cd test and press Enter. This will change your directory to the newly created “test" folder.

Step 11: Type notepad test.txt and press Enter. This will open Notepad and create a file called "test.txt" in the "test" folder. Click "Yes" when prompted.

Step 12: In the Notepad file, type "This Is My First File Created Using Command Line Prompts."

Step 13: Click "File" and select "Save" to save the file.

Step 14: Close the Notepad file and return to the Command Prompt.

Step 15: Type test.txt and press Enter. This command will display the content of the "test.txt" file in the Command Prompt.

Step 16: Congratulations! You've successfully created a file using CMD commands in Windows.

How to Create File in CMD? (CMD Create File 5 Commands)

The Windows Command Prompt offers several quick methods to create text files directly from the terminal—no need to open a graphical interface. Let’s explore a few different commands that can help you generate files instantly.

Method 1: How to Create File in CMD Using the echo Command (command line create file)

Step 1: Launch Command Prompt
Press Win + R, type cmd, and hit Enter to open the Command Prompt window.

Step 2: CMD Create File
Run the following command to create a text file named Rapture.txt with a blank line inside:

echo. > Rapture.txt

This creates the file in your current directory. You can also add custom content like this:

echo This is a test file. > Rapture.txt

Success! You've created a text file using the echo command.

Method 2: How to Create File in CMD Using the copy con Command

Step 1: Type the following in CMD:

copy con Rapture.txt

Step 2: Enter the content for your file, then press CTRL + Z and hit Enter to save it.

This command creates and saves a file named Rapture.txt in the current folder with the content you type in manually.

Well done! Your file has been saved without opening any editor.

Method 3: Using the Notepad Command

This command opens Notepad and either creates a new file or edits an existing one.

notepad Rapture.txt

  • Type your content in Notepad.
  • Press CTRL + S to save, and then close the window.

Simple and effective! You’ve created or modified a file using Notepad via CMD.

Method 4: Create a File with a Specific Size Using fsutil

If you want to generate a blank file of a particular size, use:

$ fsutil file createnew Rapture.txt 10

This will create a file named Rapture.txt with a size of 10 bytes.

Note: This command may require administrative privileges.

File created with exact size using fsutil.

Method 5: Use type nul to Make an Empty File

To create a completely blank file instantly, run:

type nul > Rapture.txt

This creates an empty text file named Rapture.txt in the current directory.

Quick and easy—your empty file is ready!

How to Create an Empty File Using CMD in Windows? (CMD Create File)

Creating an empty file via the Command Prompt in Windows 11 is a simple process. Just follow the steps below:

Step 1: Open Command Prompt
Start by launching the Command Prompt. You can do this by typing "Command Prompt" into the Start menu search bar and pressing Enter.

Step 2: Move to the Desired Directory
Next, navigate to the folder where you want to create the empty file. Use the cd command followed by the folder path. For example:

cd C:\Users\YourName\Desktop

Step 3: Create an Empty File Using Redirect Operator
To generate an empty file, use the redirect symbol > followed by the file name. Here's how:

> emptyfile.txt

Alternatively, you can use:

type nul > emptyfile.txt

Step 4: Verify the File
Run the dir command to list the contents of the directory and confirm the new file has been created:

dir

That’s it! You've successfully created an empty file using CMD in Windows.

How to Create a Text File Using CMD in Windows?

Creating a text file through the Command Prompt (CMD) in Windows is straightforward. Just follow these steps:

Step 1: Open Command Prompt

Press the Windows key, type cmd in the search bar, and press Enter. This opens the Command Prompt window.

Step 2: Navigate to Your Desired Directory

Use the cd command to move into the folder where you'd like the new file to be stored. For example:

cd Desktop

This will switch the working directory to your Desktop.

Step 3: Create a New Text File

You can use Notepad through CMD to create a file. Type the following:

notepad filename.txt

Replace filename with whatever you'd like to name your file. Notepad will open with a blank document.

Step 4: Add Content and Save

Type your content in the Notepad window. Then, press Ctrl + S or go to File > Save, choose a location and file name (if prompted), and click Save.

Step 5: Close Notepad

After saving, close Notepad. Your text file is now created and saved in the selected directory.

How to Create a Text File Inside a Folder Using CMD? (CMD Create File)

You can also generate a text file directly inside a folder using a simple echo command.

        1. Launch CMD as before. Navigate to the directory where your folder exists using cd. For example:

cd Desktop

        2. Create the file in the folder using this command:

echo. > foldername\filename.txt

Replace foldername with the name of your folder, and filename with your desired file name.

        3. Use dir to check that the file was created:

dir

Your file is now inside the target folder. You can open and edit it with any text editor or modify it using additional command-line tools.

Conclusion

Learning how to create files and folders using the Command Prompt provides a fast and efficient way to manage your system. Whether you're a beginner or an experienced user, using CMD create file helps in streamlining your workflow. With this knowledge, you now have a solid understanding of how to create files in CMD on Windows 10, empowering you to handle file management tasks more effectively from the terminal.

BlueVPS offers lightning-fast KVM VPS deployment with instant setup across 20 global locations, ensuring you can get started without delay. With convenient remote access and full control, managing your virtual server has never been easier. Whether you prefer Linux or Windows, BlueVPS supports both operating systems and provides access to all major control panels. Built on KVM virtualization technology, each VPS comes with 100% dedicated resources, guaranteeing consistent performance and reliability. Backed by 24/7 customer support, BlueVPS is the perfect solution for developers, businesses, and power users who demand speed, control, and dependable service.

Blog