How to Change Directories in Command Prompt? - GeeksforGeeks (2024)

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.

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

How to Change Directories in Command Prompt? - GeeksforGeeks (1)

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 on OS 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 Data Structure.

Different Levels of Directories

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

How to Change Directories in CMD at Different Levels?

Before moving ahead with Changing Directory to Windows Folders, we have to understand Directory Changing to Different Levels. Let us discuss 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 use the `cd` command followed by the directory name. For example:

How to Change Directories in Command Prompt? - GeeksforGeeks (2)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (3)

Changing Directories in the Parent Directory

Level 3: Change Directories to Subdirectories Level

Open CMD or 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:

How to Change Directories in Command Prompt? - GeeksforGeeks (4)

Changing Directories to Subdirectories

Level 4: Change Directories in Nested Subdirectories Level

Open CMD. 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:

How to Change Directories in Command Prompt? - GeeksforGeeks (5)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (6)

Changing Directories to Leaf Directories

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

How to Change Directories in Command Prompt to Different Folders?

Now, after discussing Directory Change in Different Levels, we will now discuss all the possible methods that are required to Change Directories to Folders 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.

How to Change Directories in Command Prompt? - GeeksforGeeks (7)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (8)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (9)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (10)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (11)

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:

How to Change Directories in Command Prompt? - GeeksforGeeks (12)

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

8. Using the “dir” command:

It is used to list all Windows 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.

How to Change Directories in Command Prompt? - GeeksforGeeks (13)

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.

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

Conclusion

The complete guide on “How to Change Directories in CMD (Command Prompt)” is discussed above. Don’t worry if it feels a bit confusing at first. With time, you’ll become a Command Prompt Expert. Practice will make you more comfortable with these Simple Windows Commands for changing Directories at Different Levels in Command Prompt.

Also Read

  • Most Useful CMD Commands in Windows
  • 10 Ways to Open the Command Prompt in Windows 10
  • How to Change Colours in Command Prompt in Windows?

How to Change Directories in Command Prompt – FAQs

How can I change the quotes used in Directory of 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

Next

How to Change Colours in Command Prompt in Windows?

Share your thoughts in the comments

Please Login to comment...

How to Change Directories in Command Prompt? - GeeksforGeeks (2024)

References

Top Articles
Latest Posts
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 5493

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.