批次處理CD命令

2019-10-16 22:59:47

批次處理CD命令用於更改不同的目錄,或顯示當前目錄。

語法

cd

範例

以下範例顯示了如何以各種方式使用cd命令。

@echo off
Rem The cd without any parameters is used to display the current working directory
cd
Rem Changing the path to Program Files
cd \Program Files
cd
Rem Changing the path to Program Files
cd %USERPROFILE%
cd
Rem Changing to the parent directory
cd ..
cd
Rem Changing to the parent directory two levels up
cd ..\..
cd

上述命令將在更改到各個檔案夾位置後顯示以下輸出。

C:\Users\Administrator
C:\Program Files
C:\Users\Administrator
C:\Users
C:\