Objectives:
Learn the basics of Windows Command Prompt
Practice navigating your computer using CMD
Relate to the concept Keep it Simple!
Command Prompt (CMD) is a tool that lets you control your computer by typing instructions
No need for a mouse or the GUI!
cd [folder] | Changes to the specified directory (e.g., cd GC_Project)
cd %HOMEPATH% | Goes to your user’s home directory
mkdir [folder] | Creates a new directory (folder)
type nul > [filename] | Creates a new, empty file (e.g., type nul > notes.txt)
dir | Lists files and folders in the current directory
cls | Clears the Command Prompt screen
move [file] [destination] | Moves a file into a folder (e.g., move notes.txt backup\)
rename [old] [new] | Renames a file (e.g., rename todo.txt tasks.txt)
copy [file] [destination] | Copies a file to a folder (e.g., copy tasks.txt backup\)
del [filename] | Deletes a file (e.g., del script.txt)
dir /a:h | Lists hidden files in the directory
echo [text] > [filename] | Writes text to a file (e.g., echo Hello > file.txt)
type [filename] | Displays the contents of a file (e.g., type greeting.txt)
exit | Closes the Command Prompt window
Getting Started
To increase the font size in the window, press the CTRL key and the + key until you reach your desired font size.
Step 1: Open the Command Prompt
Press the Windows key and the R key at the same time, type cmd, and press the Enter Key
Step 2: Go to your Home Directory
type cd %HOMEPATH%
Step 3: Make a New Folder
mkdir GC_Project
cd GC_Project
Create and View Files
Rather than entering each command individually, you can create all of the files in one command by separating each file name and type with a comma:
type nul > notes.txt, todo.txt, script.txt
Additionally, you can clear the interface by using the cls command!
Step 1: Create Empty Files
type nul > notes.txt
type nul > todo.txt
type nul > script.txt
Step 2: View the Files
dir
Organize Files
You can use the cls command to clear the window, it will not undo any of your previous actions, it will simply erase the space for easier navigation.
Step 1: Create a Backup Folder
mkdir backup
Step 2: Move One File to the Backup Folder
move notes.txt backup\
Step 3: Rename a File
rename todo.txt tasks.txt
Try it out!
Step 1: Copy a file
copy tasks.txt backup\
Step 2: Delete a File
del script.txt
Step 3: Return to Your Home Directory
cd %HOMEPATH%
Bonus Challenges!
Challenge 1: List hidden files
dir /a:h
Challenge 2: Write to a file and view it
echo Hello World > greeting.txt
type greeting.txt
Challenge 3: Remove all files and folders from the GC_Project directory
Note that you cannot remove a directory if it contains files or subdirectories, and you will need to make use of the flags /s and /q.
A flag modifies the behavior of a command.
/s | deletes all files and subdirectories
/q | quiet mode, no prompt for confirmation
Caution: These commands are irreversible. Double-check the directory path before executing.