Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home»Windows»How To Change Directory In Command Prompt (CMD)

How To Change Directory In Command Prompt (CMD)

Abhishek SilwalBy Abhishek SilwalAugust 16, 2022
change-directory-in-cmd

CMD or Command Prompt is the default Command-line Interface of Windows. It is extremely helpful for diagnosing or troubleshooting your computer. But like any interface, its main job is to automate tasks and run the system more efficiently.

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.

Table of Contents

  • Changing the Working Directory in CMD
    • Change to Sub-folder in CMD
    • Change to Parent Folder in CMD
    • Change to Another Directory of the Current Drive
    • Change Drive Partition
    • Using Environment Variables
    • Open Particular Directory in CMD From File Explorer
    • Drag and Drop Folder to CMD
  • Related Questions
    • Can’t Change Directory in CMD. What to Do?
    • How to Change Directory on Mac or Linux Terminal?
    • How to Create or Delete a Directory in CMD?

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] [<drive>:][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 [<relative path>]. 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 directory subfolder

Advanced Tip:

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.

Change to Parent Folder in CMD

There is a simple command to change to the parent directory: cd..

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 parent folder

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 [<full path of a folder>] 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:

  1. Right-click on the Title bar of CMD and select Properties.
    cd-full-path-properties
  2. In the Options tab, check/uncheck Enable Ctrl key shortcuts and click Ok.
    command-properties-enable-ctrl-shortcuts

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.

change drive
Fun Fact: You can change to the directory of another drive, say, cd C:\Users\default while in D:\>. After that, changing the drive to C: takes you to C:\Users\default even if it had another working directory when you left it.

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:

%systemdrive% - C:\
%windir% - C:\Windows
%programfiles% - C:\Program Files
%userprofile% - C:\Users\<Current User>
%localappdata% - C:\Users\<Current User>\AppData\Local
%temp% - C:\Users\<Current User>\AppData\Local\Temp

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.

Related Questions

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 <folder name> or mkdir <folder name>. Similarly, you need to enter rd or rmdir <folder name> 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 <folder name> to create/delete it from any working directory.

how-to
Abhishek Silwal
  • LinkedIn

Abhishek Silwal is an Electronics Engineer and a technical writer at TechNewsToday. He specializes in troubleshooting a wide range of computer-related issues. His educational background in Electronics Engineering has given him a solid foundation in understanding of computers. He is also proficient in several programming languages and has worked on various robotics projects. Even in his early days, he used to tinker with various computer components, both hardware, and software, to satiate his curiosity. This experience has given him a breadth of experience that goes beyond his educational qualification. Abhishek has been writing articles on dealing with varieties of technical issues and performing specific tasks, especially on a Windows machine. He strives to create comprehensive guides on fixing many system and hardware issues and help others solve their problems. You can contact him at abhisheksilwal@technewtoday.com

Related Posts

amd-software-not-opening

How to Fix AMD Software Not Opening

March 3, 2023
how to create a folder

7 Ways to Create a Folder on Windows

March 3, 2023
turn off automatic updates windows

How to Turn Off Automatic Updates on Windows

March 2, 2023
Memory-Compression

What is Memory Compression in Windows? Should You Enable or Disable It

March 1, 2023
dism-vs-sfc-vs-chdsk

DISM, SFC, CHKDSK: What’s the Difference

February 28, 2023
how-to-open-exe-file

4 Ways to Open EXE File

March 2, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
Memory-Compression

What is Memory Compression in Windows? Should You Enable or Disable It

March 1, 2023
dism-vs-sfc-vs-chdsk

DISM, SFC, CHKDSK: What’s the Difference

February 28, 2023
bios-settings-for-gaming

Best BIOS Settings for Gaming

February 16, 2023
You may also like
how-to-clean-hp-printer-rollers

How to Clean HP Printer Rollers

March 3, 2023
keyboard input lag

9 Ways to Fix Keyboard Input Lag

March 3, 2023
keyboard key is stuck

How to Fix a Stuck Key on a Keyboard

March 3, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.