CD, CHDIR commands and %CD% Variable

The CD command changes or shows the current directory of pBat command prompt.

The %CD% variable expands to the current directory of pBat command prompt.

Synopsis

CD  [[/d] path]
CHDIR [[/d] path]

Changes or displays the current working working directory.

If neither path nor /d is specified, then CD will display the path to the current working directory.

On Windows (since version 2014.0.9b), the CD command behaves allmost the same way as cmd’s CD does, supporting the possibility to have several current working directories depending on the current drive. The CD command behaviour is the following :

Variables

%CD%

Expands to the current working directory. This variable is read-only and can not be modified using SET. Depending on pBat version, the undocumented %__CD__% variable defined by cmd might as well be defined by pbat, however its use is strongly discouraged.

%=X:%

Expands to the current working directory associated with drive X:. This undocumented variables are also defined by cmd.exe, even though they are undocumented. However, this family of variable is not defined on UNIX-like OSes.

Bogus

On Windows, CD may actually change current directory to a path that does not exist if path is made of dots. Indeed, internal windows routines fail to identify such folders as non-existing, thus allowing pBat to change directory. For example:

CD ...

Compatibility

Fully compatible with cmd.exe.

Available since version 0.4

See also

Variable, Specifications Index, Command list