You may have thought that Command Prompt is just for experts. But, you are wrong. Command Prompt has many useful features and is fairly easy to use. You just need to learn how. In this article, you will read about Command Prompt, how to use its primary commands and how to learn more about it.
So, what is Command Prompt anyway?
Command Prompt, or cmd.exe, is a command processor that comes with Windows operating systems. Some of its most popular operations are changing directories, creating and renaming folders, deleting files and even launching programs from it.
As you can see, these are all quite basic commands that anyone can work with and make use of. Now, let’s talk about the basic commands.
Just to clarify, this article applies only to Windows 7 and up.
CD – Change Directory
With this command, you are able to quickly switch to any directory you want. Once you open Command Prompt, type in CD\ and press Enter. You’ll notice that you are now at the root of the directory tree.
If you want to go to a specific folder, type CD Folder in the command line. For example, if you want to change directory to the System 32 folder, type cd windows\system32 and press Enter. Notice how the subfolders are divided with \.
By typing the right path, you can navigate to any folder you want. If you want to go back one folder, just type CD at the end of the line and press Enter. Now your directory has changed to the Windows folder.
A quick note: it doesn’t matter if you are using capital or lowercase letters. Command Prompt will recognize the command nonetheless.
Accessing a Drive
You just need to type the letter of the drive and ‘:’. Example: if you want to go from drive C, which you are already in, to drive D, type in D: and press Enter.
In case you want to change the drive and directory at the same time, type in the cd command and then /D. So, if you want to access the Windows folder again, but now from the D drive, type cd /d c:\windows and press Enter.
DIR – Viewing Contents of a Folder
With this handy tool, you can view contents of any folder you’d like. As an example, we’ll try viewing a new folder (Scuttlenet.com) created on the D drive.
Type in “cd /d D:\scuttlenet.com” and press Enter to change the directory to the d drive. Then type ‘DIR’ and press Enter again. Now you’ll see the display of the folder’s contents and some information about them (size, date of its last modification, etc.).
MKDIR – Creating a New Folder
You can use both MKDIR and MD; they will be recognized as the same command. Now, for instance, we want to create a new folder. If the directory is already switched to where you want to create your folder, just type in mkdir with the name of the new folder and press Enter.
Example: mkdir Scuttlenet.com
To test whether it worked, use the DIR command to see the contents and if the new folder was successfully created.
Don’t forget to change the directory to where you want your new folder to go. Otherwise, it will be created somewhere else.
There’s another way to make a new folder that doesn’t require being in the directory first. Just type MKDIR, followed by the location of where you want your new folder to be and its name.
Example: mkdir d:\Scuttlenet.com\. And of course, press Enter.
If you need to create subfolders together with a new folder, type MKDIR again, now with the names of the folder and subfolders divided by ‘\’.
Example: mkdir d:\New_Folder\New_Folder_2\New_Folder_3.
Every folder you add to this command will be added inside the previous one. In this case, New Folder 3 is inside the New Folder 2. And if we create a New Folder 4, it would be inside the New Folder 3.
REN – Renaming Files and Folders
Changing the name of a folder or file requires the REN command. If you want to rename a folder, you need to type in REN, then type the name of the folder of which you want to change the name, as well as the new name. For example, if we want to change the name of our New Folder to Test, we need to type ren New_Folder Test.
Renaming files is basically the same as renaming folders. Type in REN, then the name of the file with its extension. Now type the new name, with the extension as well.
Let’s say there is a picture named desert.jpg, and we want to change its name to flower.jpg.
We will do so by typing ren desert.jpg flower.jpg.
COPY and XCOPY – Copying Files and Folders
The COPY command lets you copy a file or folder from one directory to another. You can also change the name of the copied file with it.
Type COPY, along with the location and file name. Then type the new location and new file name. Don’t forget to press Enter. Now, as an example, let’s say we want to copy that picture file desert.jpg from Scuttlenet.com (Folder) to Pics (Folder). And we also want to rename it to flower.jpg.
In this case, we need to type
copy d:\Scuttlenet.com\desert.jpg d:\Scuttlenet.com\Pics\flower.jpg.
If the operation is successful, you will get a confirmation message.
In case you want to change the extension of a file, you don’t have to type in the location. For example, type copy desert.jpg desert.png. So, as you can see, the name remains the same, but a new file has been created in the same directory, just with a different extension.
Say you want to copy an entire folder with all of its contents. For this, you need to use the XCOPY command. Also, along with it, you need to use the /S and /I commands. /S will specify that you want to copy your folder with its contents and /I will create a new directory for you in case you typed in a non-existent one.
For example, we need to copy our well-known Scuttlenet.com ( folder ) to the C drive.
xcopy /s /i d:\Scuttlenet.com c:\Scuttlenet.com
DEL – Deleting Files
If you want to delete all files from a folder, you need to use the DEL command, along with the name of the folder. After pressing Enter, you’ll receive a message asking you to confirm whether you want to delete it. Then you should type Y to confirm (or N if you want to cancel) and press Enter.
For instance, if we wanted to delete all files from our newly created folder, we’d need to type del Scuttlenet.com.
When it comes to hidden files, you can just add /H before the file or folder name.
Deleting a single file requires typing the DEL command along with that file name. So, to delete our desert.jpg file, we will run del desert.jpg and press Enter.
Another useful command is DEL *.extension. This command is used to delete all files that have the specified extension. For example DEL *.JPG will delete all files that have the .JPG extension.
Also, DEL Test*.* will delete all files that begin with Test.
You may have noticed that there was no mention of deleting entire folders so far. That’s because there is no DEL command to do so. However, you can use RD (remove directory) command. Following the previous example, we would type rd Scuttlenet.com.
To launch an application, you need to change the directory to the one where its .exe file is. Then, you can type the name of the application.
Say we need to launch Paint and the current directory is our scuttlenet.com. We need to navigate to the right folder first, which is the Windows System 32 folder. We will do so by typing cd /d c:\windows\system32\ and pressing Enter. Then we will write mspaint.exe or just mspaint and press Enter again.
HELP – Command Prompt Help
Once you’ve opened the Command Prompt, type HELP, and press Enter. You will get a complete list of 280 commands and information about each of them.
If you want to know more about a certain command, you can type HELP followed by the name of that command. You can also type the name of the command and /? to get the same result. You will then be presented with important information about that particular command.
I think it’s safe to say that understanding Command Prompt isn’t too difficult. Anyone can learn to work with it, even those who are hearing about it for the first time right now. With a little practice, Command Prompt could become a valuable tool when using your computer.