Imagine trying to open a file in Command Prompt but getting an error every time. This isn’t because the file doesn’t exist; it’s because you are in the wrong folder.
That’s exactly how Command Prompt works. Before you run a program, access a file, or execute a script, you must first navigate to the correct directory. If you don’t know how to move between folders properly, many commands simply won’t work.
In Windows, changing directories is done using the cd (Change Directory) command. But it’s not just about typing cd foldername.
There are different situations:
- Moving inside a folder
- Jumping to a completely different path
- Switching drives (C: to D:)
- Going back to the previous folder
- Accessing folders with spaces in their names
In this article, you will learn each method clearly with proper step-by-step processes and practical examples, so you can confidently navigate through Command Prompt without confusion.
Also Read: How to Create a File in Command Prompt?
Understanding the cd Command
The main command used to change directories is:
cd
- cd means Change Directory. It tells the Command Prompt to move from your current location to another folder.
Before changing directories, it’s quite important to know where you currently are.
To know this, follow these steps:
- Type the following command & press ‘Enter’:Copied!
cd - You will see something like:Copied!
C:\Users\yourcurrentdirectory
This is your current directory!
Methods to Change Directory in Command Prompt
There are a few methods to change the directory in the Command Prompt. Let’s understand each & every method:
Also Read: How to Check Folder Permission in Windows CMD?
➢ Method 1: Change Directory to a Folder Inside the Current Folder
You can use this method when the folder you want to enter is inside your current directory.
For Example:
- In the given situation, your current directory is:Copied!
C:\Users\yourdirectory
- Here, yourdirectory refers to your directory name.
- You want to go to:Copied!
Documents
Step-by-Step Process:
- Open Command Prompt.
- Firstly, you have to confirm your location using:Copied!
cd - In that, type & press ‘Enter.’Copied!
cd Documents - Now, you have to check the location again using the ‘cd’ command:
- You will now see:Copied!
C:\Users\yourdirectory\Documents
That’s it! You have successfully entered the Documents folder!
Also Read: How to Check Laravel Version in Windows CMD?
Method 2: Change Directory Using Full Path
You can use this method when the folder is not inside your current directory.
This method works from anywhere!
Example:
- If you want to go directly to:Copied!
C:\Users\yourdirectory\Downloads
- Here, yourdirectory refers to your directory name.
Step-by-Step Process:
- Open Command Prompt.
- Here, you have to type the complete path:Copied!
cd C:\Users\yourdirectory\Downloads - After typing, press ‘Enter.’
- Now, you have to verify using the ‘cd’ command:
You are now inside the Downloads folder!
This method avoids moving through each folder step by step.
Also Read: How to Check the SQL Version in Windows CMD?
Method 3: Change Drive and Directory at the Same Time
Before understanding this method, you need to know one important thing:
In Command Prompt, changing a directory and changing a drive are two different actions.
For Example:
- C: is one drive
- D: is another drive
If you are currently working in the C: drive and try to move directly to a folder on the D: drive, Command Prompt will not automatically switch drives unless you tell it to.
That’s where many users get confused.
To change both the drive and the directory at the same time, use /d.
For Example:
- Your current location is:Copied!
C:\Users\yourdirectory
- Here, yourdirectory refers to your directory name.
- Your target location is:Copied!
D:\Projects
Step-by-Step Process:
- In CMD, you have to type the below command & press ‘Enter’:Copied!
cd /d D:\Projects - Now, you have to check the location using the ‘cd’ command:
Now you will see:
D:\Projects
Also Read: How to Check Angular Version in Windows CMD?
➢ Method 4: Move One Level Up (Go Back)
Sometimes, if you need to go back to the parent folder, you can use this method.
- You have to use:Copied!
cd ..
Example:
- If your current location is:
Copied!C:\Users\yourdirectory\Documents
- Here, yourdirectory refers to your directory name.
Process to do this:
- Type the following command & press‘Enter’:
Copied!
cd .. - Now, you have to check the location with the ‘cd’ command:
- The New location will be:
Copied!C:\Users\yourdirectory
- Each .. moves you one level up.
- To move two levels up:
Copied!cd ..\..
Also Read: Guide to Check PHP Version in Windows CMD
➢ Method 5: Go Directly to Root Directory
The root directory is the main folder of a drive.
- To go to the root:
Copied!cd \
Example:
- The Current location is:
Copied!C:\Users\yourdirectory\Documents
- Here, yourdirectory refers to your directory name.
Process to do this:
- Firstly, you have to type & press ‘Enter’:
Copied!cd \ - After that, you have to check the location with the ‘cd’ Command:
- You will be at a new location:
Copied!C:\
- You are now at the top level of the drive.
Also Read: Guide to Check Node Version in Windows CMD
➢ Method 6: Change Directory When Folder Name Has Spaces
If a folder name contains spaces, you must use double quotes.
Example Folder:
| Program Files |
Incorrect Command:
| cd Program Files |
- This will give an error.
Correct Process to do this:
You have to always use quotes for folder names with spaces.
- You have to type the command & press ‘Enter’:
Copied!cd “Program Files”
OR
- If you are using a full path, run the command:
Copied!cd “C:\Program Files”
Useful Supporting Command: dir
Before changing directories, you can list folders using:
dir
This shows all files and folders in your current location. It helps confirm the correct folder name.
Also Read: A Guide To Locating & Editing a Host File in Windows
Quick Command Reference
| Task | Command |
| Enter folder | cd foldername |
| Use the full path | cd C:\path\folder |
| Change drive & directory | cd /d D:\folder |
| Move one level up | cd .. |
| Go to the root | cd \ |
| Folder with spaces | cd “Folder Name” |
| Show current directory | cd |
| List folders | dir |
Also Read: What is Telnet Command in Windows & How to Use it?
Conclusion
Changing directories in Command Prompt is not complicated, but doing it correctly is essential. Every command you run depends on your current location. If you are in the wrong directory, even the correct command will fail.
By understanding how to:
- Move inside folders
- Jump using full paths
- Switch drives
- Go back to parent folders
- Handle folder names with spaces
You gain complete control over navigation in Command Prompt!
Practice these methods a few times, and directory navigation will become second nature. Once you master this, working with files, programs, and scripts in Command Prompt becomes much easier and more powerful.
