Displays the name of the current directory or changes the current directory.
CHDIR /?
CHDIR [[/D] [drive:][path] [...]]
Display the current directory name of a specified drive:
CHDIR drive:
Display the current drive letter and directory name:
CHDIR
or
CD
You can also change directory using the
PUSHD command.
Equivalent Linux BASH commands:
cd - Change Directory
pwd - Print Working Directory
The root directory is the top of the directory hierarchy for a drive. To return to the root directory, type:
CD \
If you are working in the \PUBLIC\JONES directory on drive C and you change to drive D, you can copy files to and from the \PUBLIC\JONES directory by specifying only the drive letter C:.
You can change the current directory on another drive by specifying the drive letter on the command-line when you use CHDIR or CD.
The current directory string is converted to use the correct CASE. So CD C:\wiNnt would actually set the current directory to C:\Winnt.
CD does not treat spaces as delimiters, so it is possible to CD into a subfolder name that contains a space without surrounding the name with quotes: cd \My folder is the same as: cd "\My folder"
An asterisk can be used to complete a folder name: CD pro* will move to: C:\Program Files
Note: that the syntax above requires a space - after the CD and before the foldername.
Tab Completion is disabled by default (it has been known to create difficulty when using a batch script to process text files that contain TAB characters). This allows changing current folder by entering part of the path and pressing TAB. CD Prog [PRESS TAB] Will go to C:\Program Files\
Tab Completion is turned on by setting the registry value:
REGEDIT4 [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "CompletionChar"=dword:00000009
Moving down the folder tree with a full path reference to the ROOT folder:
CD \winnt\java
Moving down the folder tree with a reference RELATIVE to the current folder:
CD java
Moving up and down the folder tree in one command:
CD ..\system32
Either of these commands changes your current directory to the directory named PRIMETIM:
CHDIR \PRIMETIM CD \PRIMETIM
Suppose you have a directory named SPECIALS with a subdirectory named SPONSORS. To change your current directory to \SPECIALS\SPONSORS, type:
CD \SPECIALS\SPONSORS
Or, if your current directory is \SPECIALS, you can use to change to the \SPECIALS\SPONSORS directory:
CD SPONSORS
To change from a subdirectory back to the parent directory, type:
CD ..
To display the name of the current directory, you can use CHDIR or CD without a parameter. For example, if your current directory is \PUBLIC\JONES on the disk in drive B, type CHDIR to see:
B:\PUBLIC\JONES
If you are working on drive D and you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories on drive C to the root directory on drive D, type:
CHDIR C:\PUBLIC\JONES COPY C:*.* D:\ CHDIR C:\PUBLIC\LEWIS COPY C:*.* D:\
If, instead, you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories to your current location on drive D, type:
CHDIR C:\PUBLIC\JONES COPY C:*.* D: CHDIR C:\PUBLIC\LEWIS COPY C:*.* D:
Changing the Current drive, simply enter the drive letter colon:
E:
To change drive and directory at the same time, use CD with the /D switch:
CHDIR /D E:\utils
none.