Open In App

How to Change Directories in Command Prompt?

Last Updated : 12 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Windows Command Prompt is a powerful tool in the world of computing for those who are comfortable with text-based interactions rather than Graphical User Interface(GUI). Using the Command Line Tool on Windows, we can achieve any target even navigating into some folders using Change Directories in CMD feature.

The Windows Command Line Tool comes up with a feature that allows you to move inside any Windows Directory with some specific Windows Commands & Symbols. We used to perform such tasks using Windows File Explorer. However, if are aiming to become a computer expert, do understand the process to Switch Windows Directory in Command Prompt.

In this article, we will learn How to Change Directories in Command Prompts, Change Directories at Different Levels, Troubleshooting Problems While Changing Directories, and master essential commands.

How-to-Change-Directories-in-CMD-(Command-Prompt)

Quick Preview to Change Directory in Command Prompt:

  1. Use the CD Command in Windows to change most directories at the different levels.
  2. You can directly put up the Folder Path along with the CD Command to get inside of it.
  3. To Move inside the Parent Path, the cd .. command is highly used.
  4. The Drag & Drop process can be used on the directories to get the path on CMD.

What are Directories?

Before diving into the specifics, let’s understand what are Directories, Different Operations on Directories, and how to change directories at different levels.

Directories are nothing but a file system that contains information needed to access files. It’s like folders on your computer where you can organize and store files. They form a hierarchical structure, which means they have different levels, similar to a tree.

Different Levels of Directories

  • Roots Directory
  • Parent Directory
  • Subdirectory
  • Nested Subdirectory
  • Leaf Directory

How to Change Directories in CMD at Different Levels?

Now, we will be discussing all the methods for changing directories in CMD at different levels:

Level 1: Change Directories in the Root Level

Open Command Prompt. To change to a directory in the root directory (like “C:\” on Windows), you can directly use the `cd` command followed by the directory name. For example:

Root-Directory

Changing Directories in the Root Directory

Level 2: Change Directories in the Parent Level

Open Command Prompt. To move to a directory within the parent directory (like going from “Documents” to “Users”), simply use the `cd` command followed by `..` to go up one level, and then the name of the parent directory. For example:

Parent-Directory

Changing Directories in the Parent Directory

Level 3: Change Directories to Subdirectories Level

Open Command Prompt. To enter a subdirectory within your current directory (like going from “Documents” to “Photos”), just use the `cd` command followed by the name of the subdirectory. For example:

Subdirectories

Changing Directories to Subdirectories

Level 4: Change Directories in Nested Subdirectories Level

Open Command Prompt. To navigate to a deeply nested subdirectory (like going from “Documents” to “Work > Projects”), use the `cd` command with each subdirectory name, separated by a backslash (\). For example:

Nested-Subdirectories

Changing Directories in Nested Subdirectories

Level 5: Change Directories to Leaf Level

Open Command Prompt. If you want to enter a directory that doesn’t contain any subdirectories (like going to a folder with just files), use the `cd` command followed by the leaf directory’s name. For example:

Leaf-Directories

Changing Directories to Leaf Directories

Note: Remember, you can always type `cd ..` to go up one level and explore different directories easily.

Methods to Change Directories in Command Prompt

We will now discuss all the possible methods that are required to Change Directories in the Windows Command Line Tool.

Method 1: Change Directories in Command Prompt using Drag and Drop

For those who prefer a graphical approach, changing directories using drag and drop is simple. You can open File Explorer, locate the desired directory, and drag it to the Command Prompt window. This action automatically populates the command line with the directory path.

Drag-and-Drop

Change Directories Using Drag and Drop

Method 2: Change Directories in Command Prompt using Commands

Changing directories using commands may seem tricky at first, but it’s essential to get the hang of it in Command Prompt. Here are some easy methods to do it:

1. Absolute Paths:

This is like using a full address to find a place. In Command Prompt, you can use the full path to a folder to get there directly. This will take you straight to your “Documents” folder. For instance:

absolute-path

2. Relative Paths:

Think of this as giving directions from where you are. You can use `..` to move up one level and the folder name to go into a subfolder. This will take you up one level from where you are right now. For example:

Relative-path

using Relative Paths

3. Drive Letters:

Imagine switching between different drives as changing streets. To switch to a different drive, just type its letter and a colon. This will take you to the D: drive. For example:

Drive-letter

using Drive Paths

4. Environment Variables:

These are like shortcuts to important places. You can use names like `%USERPROFILE%` to go to common folders without typing the whole path. This will take you to your user profile folder. For example:

Environment-Variables

using Environment Variable

5. Tab Auto-Completion:

Think of this as your Command Prompt assistant. When you start typing a folder name and press Tab, Command Prompt will try to finish it for you. If there’s more than one option, it will show you a list.

6. Previous Directory (`cd ..`):

This is like having a “go back” button. If you want to return to the folder you were in before, just type `cd ..`. It’s like a quick way to backtrack.

7. Using Wildcards:

Wildcards are like search filters. You can use `*` to find folders based on patterns. This will take you to a folder with a name starting with “sep”. For example:

wildcard1

cd C:\Users\GFG0338\Desktop\mystuff\my_Sep_Doc>dir sep*.*

8. Using the “dir” command:

It is used to list all Files and Directories (folders) in the current directories. This helps the users to quickly see what Files and Directories are present in a particular location

For example, if you want to list the content of ” C:\Users\GFG0338\Desktop\mystuff\my_Doc “, you would type the following. This will give you a list of Files and Directories in that folder along with respective attributes.

dir-command

using dir Command

How Do I Navigate to a Specific Folder in Command Prompt?

When you want to go to a specific folder using Command Prompt, it’s like giving your computer directions. Here’s how to do it in simple steps:

  1. Open Command Prompt: First, you need to open Command Prompt. You can do this by pressing the Windows key, typing “Command Prompt,” and hitting Enter.
  2. Understand Your Starting Point: Before you start, it’s good to know where you are. Command Prompt opens in a default location, usually your user folder.
  3. Type ‘cd’ and Space: To tell Command Prompt you want to change the folder, type `cd` (which stands for “change directory”) followed by a space.
  4. Enter the Folder Name: Now, type the name of the folder you want to go to. If your folder name has spaces, put it in double-quotes. For example, if you want to go to a folder named “My Stuff,” you’d type: cd “My Stuff”
  5. Hit Enter: Press the Enter key on your keyboard. This tells Command Prompt to follow your directions and take you to the folder.
  6. Check Your Location: To make sure you’re in the right place, you can type `cd` without any folder name and press Enter. Command Prompt will show you the full path of where you are.

Remember, you can always use the `cd ..` command to go up one level if you ever want to backtrack.

Conclusion

Here is How you have learnt a complete guide on “How to Change Directories in CMD (Command Prompt)”, Don’t worry if it feels a bit confusing at first. With time, you’ll become a Command Prompt pro and breeze through directory navigation. Practice will make you more comfortable with these simple steps for changing directories at different levels in Command Prompt.

Also Read

Frequently Asked Questions to Change Directories in CMD

How can I change Directory in Command Prompt in Windows?

To change the directory in the Command Prompt of Windows, the CD Command will be highly used. The CD Command along with the Directory Name or the entire path will lead you into the desired Directory.

How to Change Directories C to D in CMD?

To switch to a different drive, just type its letter and a colon. For example: if you want to change Drive from C to D, type `D:`

How to go back to the previous Directory in CMD?

If you want to return to the previous folder you were in before, just type `cd ..`. It’s like a quick way to backtrack.

How to reset or empty the command prompt screen?

type cls and hit enter, It will clear all the previous commands on the CMD screen.

How can I list all items in any Directory using CMD?

To list all the items of any directory in Command Prompt, first, browse inside the Directory using the CD command or complete file path. Then, use the DIR command only. Executing the DIR Command will list all the items along with their details in CMD.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads