1. How to change the directory (folder) in Command Prompt (CMD)
The first command from the list is CD (Change Directory). This command enables you to change the current directory or, in other words, to navigate to another folder from your PC. For instance, the command CD\ takes you to the top of the directory tree. To see how it works, after you open the Command Prompt, type cd\ and press Enter on your keyboard. You should see how the CD\ command takes you to the top of the directory tree. In this case, to the "C:" drive.
Note that the Command Prompt is not case sensitive, meaning that you can type commands using capital letters, lowercase or any combination of them. The commands CD, cd or Cd, all work the same way.
Going back to the "CD\" command, now you are working on the root of the "C:" drive. If you need to go to a specific folder from this drive run the command "CD Folder." The subfolders must be separated by a backslash character: "\." For instance, when you need to access the System32 folder located in "C:\Windows," type "cd windows\system32\" as shown below, and then press Enter on your keyboard.
When you need to go one folder up, use the "cd.." command. Let's assume that you want to go back to the Windows folder. Type "cd.." and press Enter on your keyboard.
The effect is that your current directory changes to "C:\Windows."
2. How to change the drive in Command Prompt (CMD)
To access another drive, type the drive's letter, followed by ":". For instance, if you wanted to change the drive from "C:" to "D:", you should type "d:" and then press Enter on your keyboard.
To change the drive and the directory at the same time, use the cd command, followed by the "/d" switch. The "/d" parameter is used to change the current drive to a specific folder from another disk volume.
For instance, if you are now on the "D:" drive and you want to go back to the Windows folder from the"C:" drive, you should type "cd /d C:\Windows" and press Enter on your keyboard, like in the following screenshot.
NOTE: By typing only the drive letter you automatically move to your most recent location on that drive. For instance, if you are on "D:" drive and type "cd c:\windows" nothing seems to happen. However, if you type "c:" then the working folder changes to "c:\windows," assuming that it was the last folder you worked with on your "C:" drive.
3. How to view the contents of a directory in Command Prompt (CMD)
You can view the contents of a folder by using a command called DIR. To test it, we have created a folder named Digital_Citizen on the D: drive, with several files and subfolders. You can see them in the screenshot below.
The last time, our working folder was "C:\Windows." To navigate to the folder mentioned above, we have to use the command "cd /d D:\Digital_Citizen." To view the contents of the folder, type DIR, and press Enter. The list of the files and folders contained by it is displayed, together with some details about each of them (the size and the date and time when they were last modified).
4. How to create a new directory with Command Prompt (CMD)
You can make a new folder using the MKDIR (Make Directory) or the MD command. The syntax of these commands is "MKDIR Folder" or "MD Folder."
Let's say we need to create a new folder called Digital_Citizen_Life that is going to be placed in the "D:\Digital_Citizen" folder. To do that, we need to type "mkdir Digital_Citizen_Life" and then press Enter, as shown below.
To test if it worked, use the DIR command again. The newly created folder appears in the list.
NOTE: Do not forget that all these commands depend on the current location in the Command Prompt. For instance, if you are on the "C:" drive and type "MKDIR test," the new folder is created in the root of the "C:" drive.
Another way to create a folder that does not involve being in the desired folder is to type the complete path of the new folder. For example, if you are working on the "D:" drive and you want to create a new folder in "C:," called other_stuff, type "mkdir c:\other_stuff" and then press Enter.
When you need to create a folder with subfolders at the same time, you can use the "MKDIR Folder\Subfolder" command. For instance, if we type "mkdir Digital_Citizen_Tests\Beta\Test1" three folders are created: Digital_Citizen_Tests, Beta and Test1, in a tree-like structure.
5. How to rename files and folders with Command Prompt (CMD)
To rename files and folders, you need to use the REN (Rename) command. To rename folders, type "ren Folder NewFolderName." For example, if we wanted to rename the Digital_Citizen_Tests folder to Digital_Citizen_Final_Tests, we should run "ren Digital_Citizen_Tests Digital_Citizen_Final_Tests" and press Enter.
To rename a file, use the same command, like this: "ren filename.extension newname.extension". For instance, to rename the Digital_Citizen_Picture1.bmp file to Image0.bmp, we have to run the command "ren Digital_Citizen_Image1.bmp Image0.bmp" command.
0 Comments