Displays the name of the current directory or changes the current directory.
CHDIR [[/D] [drive:][path] [...]]
Display the current directory name of a specified drive:
Display the current drive letter and directory name:
You can also change directory using the
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:
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:
Moving down the folder tree with a reference RELATIVE to the current folder:
Moving up and down the folder tree in one command:
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:
Or, if your current directory is \SPECIALS, you can use to change to the \SPECIALS\SPONSORS directory:
To change from a subdirectory back to the parent directory, type:
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:
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:
To change drive and directory at the same time, use CD with the /D switch:
CHDIR /D E:\utils