How to Create and Delete Text Files Using Command Prompt

Efficiently creating and deleting text files using Command Prompt.

By Ajoy Kumar 4 Min Read
Create and Delete Text Files Using Command Prompt

Command Prompt, a powerful tool in Windows, provides users with a command-line interface to interact with the operating system. One of the fundamental tasks you can perform using Command Prompt is creating and deleting text files.

In this blog, we’ll walk you through the step-by-step process of creating and deleting text files, empowering you with essential skills for navigating your system efficiently.

What is a Command Prompt?

Command Prompt is a command-line interpreter application for the Windows operating system. It is also known as cmd or cmd.exe. With Command Prompt, users can execute a diverse range of commands. This tool provides a text-based interface for interacting with the system.

Although modern graphical user interfaces (GUIs) have become more prevalent, the Command Prompt remains a powerful tool for users who prefer or need a command-line approach.

How to Open Files Using Command Prompt

We can use the command prompt to open any files with the default software. Say, for example, your text editor is Notepad, then when you open the file using the command prompt it will open in the Notepad app.

Here is the command. Navigate to the directory and type the file_name_with_extension (note.txt). To change the drive use the drive name with a colon (E:), this will change the directory to E drive.

To change the directory use this command cd folder_name. For example:

cd desktop

Now to open the note.txt on the command prompt itself, then use the command

type note.txt

You can also open images using the Command prompt. Say, for example, if you want to view all the PNG files available in that directory, then you can use the following command. This will show you the list of all the png image files.

dir *.png

To open a file, use the following command:


How to Create Files Using Command Prompt

You can also create files using the command prompt. Here in this section, we will discuss how to create files using the command prompt on Windows 11. To create a file using the command prompt, you need to use theecho command.

Say, for example, you want to create one text file (note.txt) with “Welcome to thecoderworld” content, then use the following command:

echo Welcome to thecoderworld > note.txt

Now to add more content, then use this command

echo Here, we will learn how to use command prompt >> note.txt


Instead of a double greater than sign, if you use a single greater than sign, then it will override your existing text file.

How to Delete Files Using Command Prompt

Do you know? You can also delete any files using the command prompt. Here is how you can delete files using the command prompt.

Here is the command you can use to delete files:

del file_name_with_extension. For example,

del note.txt


That’s it; this is how you can create and delete text files using Command Prompt. Working with text files through the command prompt is a quick and efficient way to manage your files, especially when you want to perform tasks with precision and speed. The simplicity and power of the Command Prompt make it an indispensable tool for users who seek a streamlined approach to file manipulation.

Share This Article
He is a prominent tech writer with over six years of experience and the founder of TheCoderWord. He delivers high-quality content revolving around troubleshooting and how-to guides for Windows, Linux, macOS, Chrome, and more.
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *