
One of the first things you’ll need to learn as you become more familiar with?Command Prompt on Windows 10 is how to change directories in the operating system’s file system. There are a few ways you can do this, so we’ll walk you through them.
隨著您對Windows 10上的命令提示符更加熟悉,您需要學習的第一件事是如何更改操作系統文件系統中的目錄。 您可以通過多種方式進行此操作,因此我們將引導您完成這些操作。
First, type “cmd” in the Windows Search bar to?open Command Prompt, and then select “Command Prompt” from the search results.
首先,在Windows搜索欄中鍵入“ cmd”以打開“命令提示符”,然后從搜索結果中選擇“命令提示符”。

With Command Prompt opened, you’re ready to change directories.
打開命令提示符后,就可以更改目錄了。
使用拖放方法更改目錄 (Change Directories Using the Drag-and-Drop Method)
If the folder you want to open in Command Prompt is on your desktop or already open in?File Explorer, you can quickly change to that directory. Type?cd
followed by a space, drag and drop the folder into the window, and then press Enter.
如果要在命令提示符下打開的文件夾在桌面上或已經在文件資源管理器中打開,則可以快速切換到該目錄。 鍵入cd
后跟一個空格,將文件夾拖放到窗口中,然后按Enter。

The directory you switched to will be reflected in the command line.
您切換到的目錄將反映在命令行中。
在命令提示符下更改目錄 (Change Directories Within Command Prompt)
It’s not always convenient to open File Explorer and drag and drop. That’s why it’s cool that you can also type a command to change directories right in Command Prompt.
打開文件資源管理器并拖放并不總是很方便。 這就是為什么您還可以直接在命令提示符下鍵入命令以更改目錄的原因。
Say, for example, you’re in your user folder, and there’s a “Documents” directory in the next file path. You can type the following command in Command Prompt to switch to that directory:
假設您位于用戶文件夾中,并且下一個文件路徑中有一個“文檔”目錄。 您可以在命令提示符下鍵入以下命令以切換到該目錄:
cd Documents
cd Documents
Note that this only works if you’re in the immediate file structure. In our case, that would be (user folder) > Documents. In our current directory, we wouldn’t be able to use this method to jump to a directory nested two levels down.
請注意,這僅在您處于直接文件結構中時才有效。 在我們的例子中,該目錄為(用戶文件夾)>文檔。 在當前目錄中,我們將無法使用此方法跳轉到向下嵌套兩個級別的目錄。
So, let’s say we’re currently in the user folder and want to go to the “How-To Geek” folder, which is nested in “Documents.” If we try to jump straight to “How-To Geek” without first going to “Documents,” we get the error shown in the image below.
因此,假設我們當前位于用戶文件夾中,并且想要轉到嵌套在“文檔”中的“ How-To Geek”文件夾。 如果我們嘗試直接跳到“ How-To Geek”而沒有先去“ Documents”,則會收到下圖所示的錯誤。

Let’s take things one directory at a time, for now. As we mentioned previously, we’re currently in our user folder. We type?cd Documents
?in Command Prompt to visit “Documents.”
現在,讓我們一次將一個目錄放在一個目錄中。 如前所述,我們當前位于用戶文件夾中。 我們在命令提示符下鍵入cd Documents
以訪問“ Documents”。

We’re now in the “Documents” folder. To move down another level, we type?cd
?on the command line followed by the name of that directory.
我們現在位于“文檔”文件夾中。 要向下移動一個級別,請在命令行上鍵入cd
,然后輸入該目錄的名稱。

Now, let’s say we’re back in our user folder and want to skip that extra step and jump two directories down. In our case, this would be our “How-To Geek” folder. We type the following command:
現在,假設我們回到了用戶文件夾中,并希望跳過該額外的步驟并向下跳兩個目錄。 就我們而言,這就是我們的“ How-To Geek”文件夾。 我們輸入以下命令:
cd Documents\How-To Geek
This allows us to move two directory levels with one command.
這使我們可以使用一個命令移動兩個目錄級別。

If you ever go to the wrong directory and want to turn back, type the following command:
如果您進入錯誤的目錄并想返回,請鍵入以下命令:
This allows you to move up a level.
這使您可以向上移動一個級別。

導航提示 (A Navigation Tip)
If you want to be a bit more efficient with your directory changes, type?cd
?on the command line, followed by the first few letters of the directory you want. Then, press Tab to autocomplete the directory name.
如果要使目錄更改更加有效,請在命令行上鍵入cd
,然后輸入所需目錄的前幾個字母。 然后,按Tab鍵自動完成目錄名稱。

Alternatively, you can type cd
, followed by the first letter of the directory, and then press Tab multiple times until the correct directory appears.
或者,您可以鍵入cd
,然后鍵入目錄的首字母,然后多次按Tab鍵,直到出現正確的目錄。

查看目錄內容 (See Directory Contents)
If you’re ever lost and not sure where to go next, you can view the contents of your current directory by typing dir
?on the command line.
如果您迷路了并且不確定下一步要去哪里,可以在命令行上輸入dir
來查看當前目錄的內容。

This will give you a hint as to which directory to navigate to next.
這將提示您要導航到下一個目錄。
翻譯自: https://www.howtogeek.com/659411/how-to-change-directories-in-command-prompt-on-windows-10/