How To Change Directory in CMD (Command Prompt)
![how to change directory in cmd](https://storage.googleapis.com/static.configserverfirewall.com/images/windows10/cmd/how-to-change-directory-in-cmd.webp)
To change the directory in CMD, we use the CD
command. Alternatively, you can use the chdir
command, which works the same way.
CD path
CHDIR path
Notes
- If you run the CD command without any parameters, the current working directory is displayed.
- If you want to change the drive, for example, from
C:
driveD:
drive, you need to use the/D
option. - To list files in the Windows command prompt, use the dir command.
Examples
Change to the data directory. Since we don't specify the absolute path (full path), the data directory is a subfolder inside the current working folder.
cd data
Change the directory to C:\Program Files
:
cd "C:\Program Files"
Change to the parent directory of the current folder:
cd ..
Change the drive. For example, I am currently working in the C:
drive, if I want to change to D:
drive, I have to use /D
switch:
cd /d E:
![command prompt change drive](https://storage.googleapis.com/static.configserverfirewall.com/images/windows10/cmd/cd-command-change-drive.webp)
The following command changes the directory to the root of the current drive:
cd \
![how to change directory in command prompt](https://storage.googleapis.com/static.configserverfirewall.com/images/windows10/cmd/command-prompt-change-directory.webp)