极客和专家喜欢命令提示符(Command Prompt),因为它可以运行高级命令。幸运的是,命令提示符(Command Prompt)不仅建立在高级命令之上,还建立在简单命令之上,旨在执行基本操作。在本文中,我们将向您展示如何执行命令,例如更改当前目录、切换到另一个驱动器、查看目录内容、创建和重命名文件夹、复制、删除文件和文件夹以及从命令提示符(Command Prompt)启动应用程序。我们还将向您展示如何在使用此Windows应用程序时获得帮助。让我们(Let)开始吧:
注意:(NOTE:)本教程中共享的信息适用于Windows 10、Windows 8.1 和 Windows 7。请注意,为简单起见,我们仅使用在Windows 10中截取的屏幕截图。
1.如何在命令提示符(Command Prompt)(CMD)中更改目录(文件夹)
列表中的第一个命令是CD(更改目录)。(CD (Change Directory).)此命令使您能够更改当前目录,或者换句话说,从您的 PC 导航到另一个文件夹。例如,命令CD将您带到(CD)目录树(directory tree)的顶部。要查看它是如何工作的,请在打开命令提示符(Command Prompt)后,键入cd并按键盘上的Enter 。您应该看到CD命令如何将您带到(CD)目录树(directory tree)的顶部。在这种情况下,到“C:”驱动器。
请注意,命令提示符(Command Prompt)不区分大小写,这意味着您可以使用大写字母、小写字母或它们的任意组合键入命令。CD、cd或Cd命令都以相同的方式工作。
回到“CD”命令,现在您正在处理“C:”驱动器的根目录。如果您需要从此驱动器转到特定文件夹,请运行命令“CD 文件夹”。("CD Folder.")子文件夹必须用反斜杠字符分隔:“.” 例如,当您需要访问位于"C:\Windows,"System32文件夹时,如下所示键入"cd windows\system32" ,然后按键盘上的Enter 。
当您需要向上一个文件夹时,请使用“cd..”命令。假设您要返回Windows文件夹。键入“cd..”并按键盘上的Enter 。
效果是您的当前目录更改为"C:\Windows."
2.如何在命令提示符(Command Prompt)(CMD)中更改驱动器
要访问另一个驱动器,请键入驱动器的盘符,然后输入“:”。例如,如果您想将驱动器从“C:”更改为“D:”,则应键入“d:”,然后按键盘上的Enter 。
要同时更改驱动器和目录,请使用cd命令,然后使用"/d"开关。“ "/d"参数用于将当前驱动器从另一个磁盘卷(disk volume)更改为特定文件夹。
例如,如果您现在位于“D:”驱动器上,并且想要从“C:”驱动器返回Windows文件夹,则应键入"cd /d C:\Windows"并按键盘上的Enter ,就像下面的截图一样。
注意:(NOTE:)只需键入驱动器(drive letter)号,即可自动移动到该驱动器上的最新位置。例如,如果您在“D:”驱动器上并键入(drive and type) "cd c:\windows",似乎什么也没有发生。但是,如果您键入“c:”,则工作文件夹将更改为"c:\windows,"假设它是您在“C:”驱动器上使用的最后一个文件夹。
3.如何在命令提示符(Command Prompt)(CMD)中查看目录的内容
您可以使用名为DIR的命令查看文件夹的内容。为了测试它,我们在 D: 驱动器上创建了一个名为Digital_Citizen的文件夹,其中包含多个文件和子文件夹。(Digital_Citizen)您可以在下面的屏幕截图中看到它们。
上次,我们的工作文件夹是"C:\Windows."要导航到上述文件夹,我们必须使用命令"cd /d D:\Digital_Citizen."要查看文件夹的内容,请键入DIR,然后按Enter。显示其中包含的文件和文件夹的列表,以及每个文件和文件夹的一些详细信息(大小以及上次修改的日期和时间)。(date and time)
4.如何使用命令提示符(Command Prompt)(CMD)创建一个新目录
您可以使用MKDIR(创建目录)(MKDIR (Make Directory))或MD命令创建一个新文件夹。这些命令的语法是“MKDIR 文件夹”("MKDIR Folder")或“MD 文件夹”。("MD Folder.")
假设我们需要创建一个名为Digital_Citizen_Life的新文件夹,该文件夹将被放置在"D:\Digital_Citizen"文件夹中。为此,我们需要输入“mkdir Digital_Citizen_Life”,然后按Enter,如下所示。
要测试它是否有效,请再次使用DIR命令。新创建的文件夹出现在列表中。
注意:(NOTE:)不要忘记所有这些命令都取决于命令提示符(Command Prompt)中的当前位置。例如,如果您在“C:”驱动器上并键入(drive and type) “MKDIR test”,则会在“C:”驱动器的根目录中创建新文件夹。
创建不涉及位于所需文件夹中的文件夹的另一种方法是键入新文件夹的完整路径。例如,如果您在“D:”驱动器上工作,并且想要在“C:”中创建一个名为other_stuff的新文件夹,请键入"mkdir c:\other_stuff",然后按Enter。
当需要同时创建带有子文件夹的文件夹时,可以使用“MKDIR FolderSubfolder”命令。例如,如果我们键入"mkdir Digital_Citizen_Tests\Beta\Test1" ,则会以树状结构创建三个文件夹:Digital_Citizen_Tests、Beta和Test1 。
5.如何使用命令提示符(Command Prompt)(CMD)重命名文件和文件夹
要重命名文件和文件夹,您需要使用REN(重命名)(REN (Rename))命令。要重命名文件夹,请键入“ren Folder NewFolderName”。例如,如果我们想将Digital_Citizen_Tests文件夹重命名为Digital_Citizen_Final_Tests,我们应该运行“ren Digital_Citizen_Tests Digital_Citizen_Final_Tests”并按Enter 键(Enter)。
要重命名文件,请使用相同的命令,例如:“ren filename.extension newname.extension”。例如,要将 Digital_Citizen_Picture1.bmp文件重命名为Image0.bmp (Digital_Citizen_Picture1.bmp),(Image0.bmp,)我们必须运行命令“ren Digital_Citizen_Image1.bmp Image0.bmp”命令。
如果您想了解如何复制文件和文件夹、删除文件和文件夹、启动应用程序以及在使用命令提示符(Command Prompt)时获得帮助,请阅读本教程的第二页。
Command Prompt: 11 basic commands you should know (cd, dir, mkdir, etc.)
Geeks and experts love the Command Prompt because of the advanced commands it can run. Fortunately, Command Prompt is not built only on advanced commands, but also on simple ones, designed to perform basic operations. In this article, we show you how to execute commands such as changing the current directory, switching to another drive, viewing the contents of a directory, creating and renaming folders, copying, deleting files and folders, and launching applications from the Command Prompt. We are also going to show you how to get help when using this app for Windows. Let's get started:
NOTE: The information shared in this tutorial applies to Windows 10, Windows 8.1, and Windows 7. Note that, for simplicity, we are using screenshots taken only in Windows 10.
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 FolderSubfolder" 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.
Read the second page of this tutorial if you want to learn how to copy files and folders, delete files and folders, start an application, and get help when using the Command Prompt.