While using the GUI may be more convenient, there are many cases where you need to use CMD. For instance, when your File explorer stops responding or you need to run certain scripts. This article explains how you can change directory using CMD in different cases.

Changing the Working Directory in CMD

You can open Command Prompt by searching for it on the search bar. Or you can open Run (Win + R) and enter cmd. Additionally, pressing Ctrl + Shift + Enter after typing cmd on Run opens the elevated CMD. The normal CMD opens to your user profile folder, and the elevated one opens up to the System32 folder. This folder is your Current Working Directory (CWD) and it shows up before the ‘>’ symbol. The syntax for changing directory is cd [/d] [:][path] or cd [..]. You can also use chdir instead of cd. 

Change to Sub-folder in CMD

The command to change to a sub-folder is cd []. For instance, C:\Windows>cd System32 will take you to C:\Windows\System32.  You can also directly change to the sub-folder within the sub-folder. For example, C:\Windows>cd System32\Boot takes you to C:\Windows\System32\Boot. If you have trouble remembering all the files inside a directory, enter the dir command. It lists all the folders and files in your Current Working Directory.

Change to Parent Folder in CMD

There is a simple command to change to the parent directory: cd.. You don’t need to type the full name of the folders in the command. Pressing the Tab key after typing the initial characters will auto-complete the folder name. You can also use the ? or * wildcard characters while entering a folder name. ? replaces a character while * replaces a bunch of characters at once. You can use it together with another folder in the parent directory to change to the folder directly. For instance, C:\Windows\System32\Boot>cd..\backup changes your CWD to C:\Windows\System32\backup. You can also enter cd / to go to the root directory directly.

Change to Another Directory of the Current Drive

We have already mentioned how you can change to another directory using the path relative to the CWD. However, you can also use the command cd [] to change to the folder. It is also possible to use the keyboard shortcuts to copy and paste the folder paths as commands. You can enable/disable this option from the Command Prompt setting by using the following method: If the option is On, you can directly copy a folder and paste it to the CLI using Ctrl + V hotkey. Also, in the Command Prompt, using the direction keys while holding Shift selects the text, and pressing Ctrl + C copies the contents.

Change Drive Partition

You can’t directly change to a directory in another partition using the above commands. You need to use the /d flag (e.g., cd /d D:) or enter the drive letter and a colon (e.g., D:). While using the /d flag, you can directly change to the full path of a directory. Also, changing the drive (not the full path) changes the CWD to the location where you left the drive.

Using Environment Variables

Your system stores environment variables that represent path to particular locations. You can directly use such variables with the cd command to change to the relevant folders. Some common variables are:

Open Particular Directory in CMD From File Explorer

You can also enter cmd on your file explorer’s address bar to open Command Prompt. Your current folder will load as the CWD in such cases. This method is the easiest way to run a script or program that needs CLI from the directory.

Drag and Drop Folder to CMD

Command Prompt also allows you to drag and drop a folder in the interface. Doing so will paste the folder path to the CLI. So you can type cd along with space, drag a folder to the interface, and press Enter to change your CWD to the folder. However, keep in mind that this method is not possible on the elevated Command Prompt.

Can’t Change Directory in CMD. What to Do?

It should not happen if your syntax and the path are correct. Ensure that you are using the cd or chdir command and double-check the drive and the path. If any problems occur, try changing the directory one folder at a time while using dir to list out the contents. Also, some folders may need admin privileges to access.

How to Change Directory on Mac or Linux Terminal?

The command to change the directory for Mac and Linux Terminal is the same as CMD, i.e., cd. Most of the ways to use the command are the same.  To return to your home directory, use cd ~. The command to list out the folder contents is ls. Also, don’t forget that these Terminals are case-sensitive, unlike Windows CMD.

How to Create or Delete a Directory in CMD?

The commands to create a folder in CMD is md or mkdir . Similarly, you need to enter rd or rmdir to delete a folder. These commands will make or delete a folder inside the Current Working Directory. You can also enter a folder’s full path for the to create/delete it from any working directory.

How To Change Directory In Command Prompt  CMD  - 70How To Change Directory In Command Prompt  CMD  - 52How To Change Directory In Command Prompt  CMD  - 27How To Change Directory In Command Prompt  CMD  - 57How To Change Directory In Command Prompt  CMD  - 38


title: “How To Change Directory In Command Prompt Cmd " ShowToc: true date: “2022-12-06” author: “James Cantey”


While using the GUI may be more convenient, there are many cases where you need to use CMD. For instance, when your File explorer stops responding or you need to run certain scripts. This article explains how you can change directory using CMD in different cases.

Changing the Working Directory in CMD

You can open Command Prompt by searching for it on the search bar. Or you can open Run (Win + R) and enter cmd. Additionally, pressing Ctrl + Shift + Enter after typing cmd on Run opens the elevated CMD. The normal CMD opens to your user profile folder, and the elevated one opens up to the System32 folder. This folder is your Current Working Directory (CWD) and it shows up before the ‘>’ symbol. The syntax for changing directory is cd [/d] [:][path] or cd [..]. You can also use chdir instead of cd. 

Change to Sub-folder in CMD

The command to change to a sub-folder is cd []. For instance, C:\Windows>cd System32 will take you to C:\Windows\System32.  You can also directly change to the sub-folder within the sub-folder. For example, C:\Windows>cd System32\Boot takes you to C:\Windows\System32\Boot. If you have trouble remembering all the files inside a directory, enter the dir command. It lists all the folders and files in your Current Working Directory.

Change to Parent Folder in CMD

There is a simple command to change to the parent directory: cd.. You don’t need to type the full name of the folders in the command. Pressing the Tab key after typing the initial characters will auto-complete the folder name. You can also use the ? or * wildcard characters while entering a folder name. ? replaces a character while * replaces a bunch of characters at once. You can use it together with another folder in the parent directory to change to the folder directly. For instance, C:\Windows\System32\Boot>cd..\backup changes your CWD to C:\Windows\System32\backup. You can also enter cd / to go to the root directory directly.

Change to Another Directory of the Current Drive

We have already mentioned how you can change to another directory using the path relative to the CWD. However, you can also use the command cd [] to change to the folder. It is also possible to use the keyboard shortcuts to copy and paste the folder paths as commands. You can enable/disable this option from the Command Prompt setting by using the following method: If the option is On, you can directly copy a folder and paste it to the CLI using Ctrl + V hotkey. Also, in the Command Prompt, using the direction keys while holding Shift selects the text, and pressing Ctrl + C copies the contents.

Change Drive Partition

You can’t directly change to a directory in another partition using the above commands. You need to use the /d flag (e.g., cd /d D:) or enter the drive letter and a colon (e.g., D:). While using the /d flag, you can directly change to the full path of a directory. Also, changing the drive (not the full path) changes the CWD to the location where you left the drive.

Using Environment Variables

Your system stores environment variables that represent path to particular locations. You can directly use such variables with the cd command to change to the relevant folders. Some common variables are:

Open Particular Directory in CMD From File Explorer

You can also enter cmd on your file explorer’s address bar to open Command Prompt. Your current folder will load as the CWD in such cases. This method is the easiest way to run a script or program that needs CLI from the directory.

Drag and Drop Folder to CMD

Command Prompt also allows you to drag and drop a folder in the interface. Doing so will paste the folder path to the CLI. So you can type cd along with space, drag a folder to the interface, and press Enter to change your CWD to the folder. However, keep in mind that this method is not possible on the elevated Command Prompt.

Can’t Change Directory in CMD. What to Do?

It should not happen if your syntax and the path are correct. Ensure that you are using the cd or chdir command and double-check the drive and the path. If any problems occur, try changing the directory one folder at a time while using dir to list out the contents. Also, some folders may need admin privileges to access.

How to Change Directory on Mac or Linux Terminal?

The command to change the directory for Mac and Linux Terminal is the same as CMD, i.e., cd. Most of the ways to use the command are the same.  To return to your home directory, use cd ~. The command to list out the folder contents is ls. Also, don’t forget that these Terminals are case-sensitive, unlike Windows CMD.

How to Create or Delete a Directory in CMD?

The commands to create a folder in CMD is md or mkdir . Similarly, you need to enter rd or rmdir to delete a folder. These commands will make or delete a folder inside the Current Working Directory. You can also enter a folder’s full path for the to create/delete it from any working directory.

How To Change Directory In Command Prompt  CMD  - 76How To Change Directory In Command Prompt  CMD  - 17How To Change Directory In Command Prompt  CMD  - 13How To Change Directory In Command Prompt  CMD  - 90How To Change Directory In Command Prompt  CMD  - 64