CD: Displays the name of or changes the current directory.


 


... The examples for the command "CD"
... "CD" Excerpt from Microsoft Windows Help
... Important information, tips for the "CD" command

The command: "CD" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available

The examples for the command "CD"

The `CD` command in Windows Command Prompt is used to change the current working directory. Here are some examples with comments: Example 1: Go to a specific directory:

CD C:\Example\Directory

Description: This command changes the current working directory to "C:\Example\Directory". Example 2: Go to parent directory:

CD..

Description: This command changes the current working directory to the parent directory. Example 3: Switch back to user directory:

CD %HOMEPATH%

Description: This resets the current working directory to the user directory, regardless of which drive the user directory is located on. Example 4: Save current working directory in a variable:

SET OldDirectory=%CD%

Description: This command saves the current working directory in the environment variable `%OldDirectory%`. Example 5: Go to previous working directory:

CD /D %OldDirectory%

Description: This uses previously saved `%OldDirectory%` to return to the previous working directory. The `/D` parameter also allows changing the drive. Example 6: Change working directory and disconnect existing drive connections:

CD /DC:\New\Directory

Description: The drive can be changed with `/D`. Here the current working directory is changed to "C:\New\Directory" and existing network drive connections are disconnected. The `CD` commands are particularly useful when navigating directories on the command line or when changing the working directory within batch scripts. Note that `CD` does not require a drive letter if you are on the same drive where you want to change the working directory.

"CD" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Displays the name of or changes the current directory.

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

  ..   Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current
directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as
the on disk names.  So CD C:\TEMP would actually set the current
directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
the name with quotes.  For example:

    cd \winnt\profiles\username\programs\start menu

is the same as:

    cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

Important information, tips for the "CD" command

When using the `CD` command in the Windows Command Prompt, there are a few important points to keep in mind: 1. Specify path correctly: Make sure you specify the full or relative path to the target directory correctly. Errors in path specification can lead to unexpected behavior.

   CD C:\Example\Directory
   
2. Attention to spaces: If the path contains spaces, it should be enclosed in quotation marks to ensure that it is interpreted correctly.

   CD "C:\Directory with spaces"
   
3. Parent directory: The path "`..`" represents the parent directory. You can use it to move up a directory.

   CD..
   
4. Special Directories: There are special directories like `%HOMEPATH%` for the user directory. You can use it to change the directory without explicitly specifying the path.

   CD %HOMEPATH%
   
5. Change Drive: If you want to change the drive, add the drive letter with the path or use the `/D` switch.

   CD /DE:\A\Other\Directory
   
6. Use Variable: You can use a variable to store the current working directory and access it later.

   SET OldDirectory=%CD%
   CD C:\New\Directory
   REM... do something in the new directory
   CD /D %OldDirectory%
   
7. UNC Paths and Network Drives: The `CD` command can also be used with Universal Naming Convention (UNC) paths for network resources.

   CD \\Server\Share
   
8. Error Handling: Check the return behavior of the `CD` command, especially when using it in a script. An unsuccessful change of directory can result in unexpected behavior.

   CD Unknown directory
   IF ERRORLEVEL 1 (
       ECHO Error changing directory.
   )
   
Make sure you consider the above points to ensure the desired behavior when using the `CD` command in the Windows Command Prompt.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command CD - Displays the name of or changes the current directory.

HTTP: ... console77.000000ko0.000000index.htm/en/007.htm
0.077
17043
How to show Program Name in Windows 10 Task-Bar (Title, Icons)?
Include or exclude in Windows 8 / 8.1 / 10 compressed files when searching for files (. ZIP,. CAB, etc.)!
Erstellen von Twitter- und Facebook-Posts mit Symbolen, aber wie!
Was ist der DNS-Cache unter Windows?
Windows 8.1 or 10 to Extend test period in or delay activation tool!
Change Home Folder MS-Explorer on Windows 10/11 (to My Computer, This PC)!
Should I buy Apple MacBook or Microsoft Surface Pro?
Was ist web.archive.org für eine Seite, (Boot, Zugriffe, Datenschutz)?
Why is Windows 8.1 x64 bigger than x32 on HD and Greater on DVD?
Blu-Ray / DVD-Laufwerk defekt am PC, Notebook, oder Laptop kein Brennen mehr möglich!



(0)