In this guide, we will discover: How to Create and Delete Text Files Using Command Prompt – Easy Beginners Guide
Windows Command Prompt can do lots of things. Here, we will discuss how to create and delete files using it. Here we will also learn how to open and delete files using the command prompt.
Command Prompt is a command line interpreter for the Windows operating system. Using it, we can execute a different set of commands. You can check our list of command prompt tricks that you should know.
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 I want to view all the png files available in that directory, then I will use
dir *.png
To open a file, use the following command
file_name_with_extension
How to Create Files Using 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 can use theecho
command.
If you prefer a video tutorial, you can watch the video mentioned below:
Say, for example, I want to create one text file (note.txt) with “Welcome to thecoderworld” content, then I will use
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
Note:- Instead of a double greater than sign, if you use a single greater than sign, then it will override your 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
Conclusion
That’s it; this is how you can create and delete text files using Command Prompt. Creating and deleting text files using a command prompt is a quick and efficient way to manage your files. If you want to know the purpose of the Command Interpreter, you can follow the linked guide.
I hope this guide was helpful to you. If you liked the article, share it with your friends. If you have some suggestions or doubts, don’t hesitate to leave them in the comments section below. We will surely reply to you.