File Management Commands
Command Prompt makes it easy to create, copy, delete, and manage files. Let’s dive into some essential file management commands:
-
echo— Create a File- Usage:
echo text > filename - Example:
echo Hello World > example.txt - What it does: Creates a file named
example.txtand writes "Hello World" into it.
- Usage:
-
type— View File Contents- Usage:
type filename - Example:
type example.txt - What it does: Displays the content of
example.txtin the Command Prompt window.
- Usage:
-
copy— Copy Files- Usage:
copy source_file destination_file - Example:
copy example.txt copy_example.txt - What it does: Copies the contents of
example.txtto a new file namedcopy_example.txt.
- Usage:
-
del— Delete Files- Usage:
del filename - Example:
del example.txt - What it does: Deletes the file
example.txtfrom the current directory.
- Usage:
-
rename— Rename Files- Usage:
rename old_name new_name - Example:
rename copy_example.txt final_example.txt - What it does: Renames
copy_example.txttofinal_example.txt.
- Usage:
Directory Management Commands
In addition to managing files, Command Prompt lets you efficiently create and delete directories.
-
mkdir— Create a Directory- Usage:
mkdir folder_name - Example:
mkdir MyFolder - What it does: Creates a new directory named
MyFolderin the current location.
- Usage:
-
rmdir— Remove a Directory- Usage:
rmdir folder_name - Example:
rmdir MyFolder - What it does: Deletes an empty directory named
MyFolder.
- Usage:
-
rmdir /s— Remove a Directory with Contents- Usage:
rmdir /s folder_name - Example:
rmdir /s MyFolder - What it does: Deletes the directory
MyFolderalong with all its files and subfolders. You’ll be prompted to confirm.
- Usage:
Useful Shortcuts and Tips
-
Wildcards (
*and?):- Use
*to represent multiple characters and?to represent a single character. - Example:
Deletes alldel *.txt.txtfiles in the current directory.
- Use
-
Redirection:
- Use
>to redirect output to a file and>>to append output. - Example:
Saves the directory listing to a file nameddir > directory_list.txtdirectory_list.txt.
- Use
-
Command History:
- Use
F7to view a list of previously executed commands. - Press
F3to repeat the last command.
- Use
Practice Tasks
To solidify your learning, try these tasks:
- Create a file named
test.txtwith the text "Learning Command Prompt." - Copy
test.txtto a new file calledbackup.txt. - Rename
backup.txttofinal.txt. - Create a folder named
TestFolderand movefinal.txtinto it. - Delete the folder and its contents.
What’s Next?
In Part 3, we’ll cover:
- Advanced navigation techniques.
- Using environment variables.
- Automating tasks with batch scripts.
Keep practicing, and don’t hesitate to ask questions in the comments. Let’s keep mastering Command Prompt together!

0 Comments