Command Prompt (CMD) is a powerful built-in tool in Windows that allows you to manage files and folders without using File Explorer.
By learning a few basic commands, you can create, edit, view, rename, and delete files directly from CMD.
This beginner-friendly guide explains the most useful file management commands step-by-step.
📌 Why Use CMD for File Management?
Using CMD can help you:
Work faster
Automate tasks
Manage files efficiently
Learn basic computer administration
Understand Windows commands better
💻 Step 1: Open Command Prompt
Method 1
Press:
Windows + R
Type:
cmd
Press Enter
CMD will open.
📄 Create a New Text File
Method 1: Using ECHO Command
Create a text file with content:
echo Hello World > myfile.txt
This creates:
myfile.txt
with the text "Hello World".
Method 2: Create Empty File
type nul > myfile.txt
This creates an empty file.
📂 View Files in Current Folder
Use:
dir
This displays all files and folders in the current directory.
📝 View File Contents
Use:
type myfile.txt
CMD will display the contents of the file.
✏️ Edit a Text File
Add more text:
echo Welcome to CodeSardar >> myfile.txt
The >> symbol adds text without removing existing content.
📖 Open a File in Notepad
Use:
notepad myfile.txt
The file will open in Notepad where you can edit it normally.
📋 Copy a File
Example:
copy myfile.txt backup.txt
This creates a copy named:
backup.txt
✂️ Rename a File
Use:
ren myfile.txt notes.txt
The file name changes to:
notes.txt
🚚 Move a File
Example:
move notes.txt Documents
This moves the file to the Documents folder.
❌ Delete a File
Delete a file using:
del notes.txt
The file will be permanently removed.
🗑️ Delete Multiple Files
Delete all text files:
del *.txt
⚠️ Be careful when using wildcard commands.
📊 Useful File Commands Summary
| Command | Function |
|---|---|
| echo Text > file.txt | Create file with content |
| type nul > file.txt | Create empty file |
| dir | View files |
| type file.txt | View file content |
| echo Text >> file.txt | Add text |
| notepad file.txt | Open file |
| copy file1 file2 | Copy file |
| ren old new | Rename file |
| move file folder | Move file |
| del file.txt | Delete file |
🚀 Practice Example
Create a file:
echo Learning CMD > practice.txt
View file:
type practice.txt
Rename file:
ren practice.txt mynotes.txt
Delete file:
del mynotes.txt
⚠️ Important Tips
Double-check file names before deleting
Use
dirfrequently to verify filesAvoid deleting important system files
Practice inside a test folder first
📝 Final Words
Learning how to create, edit, and delete files using CMD is one of the most important beginner skills in Windows. These commands are simple, useful, and often used in scripting, automation, and troubleshooting.
Once you master these basics, you'll be ready for more advanced CMD operations.
For more Windows CMD tutorials and tricks, visit CodeSardar.
❓ Frequently Asked Questions
Q1. Can CMD create files without Notepad?
Yes, using commands like echo and type nul.
Q2. How do I view file contents in CMD?
Use the type command.
Q3. Is del command permanent?
Yes, deleted files usually do not go to the Recycle Bin.
