CD – Windows CMD Command

Change Directory – Select a Folder (and drive)

CHDIR is a synonym for CD.

Tab Completion

Tab completion allows changing the current folder by entering just part of the path and pressing TAB.

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.

Tab Completion is turned on by setting the registry value shown below:

A Current Directory for each drive?

Originally in MS-DOS, each drive had its own current directory, for complex historical reasons.

Now in Win32, there is one global current directory, but at the command line the appearance is still maintained that each drive has its own current directory, this is a fake-out by cmd.exe.
The location for each drive is stored using the undocumented environment variables =A:, =B:, =C: etc.

The only reason you need to be aware of this is that GUI Windows applications may have a different current directory then the command prompt. Similarly, two CMD sessions can each have a different current directory.

Errorlevels

If the Current directory was changed: %ERRORLEVEL% = 0
If the Directory does not exist or is not accessible or if a bad switch is given: %ERRORLEVEL% = 1

If Command Extensions are enabled, which they are by default, the CD command is enhanced as follows:

The current directory string is not CASE sensitive.
So CD C:\wiNdoWs will set the current directory to C:\Windows

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.


CHDIR is a synonym for CD

CD is an internal command.

You may also like...

Leave a Reply

Your email address will not be published.