ChDir

From Br Wiki
Jump to: navigation, search

The ChDir command displays or changes the current directory. You may also use the CD command - it is identical to ChDir in effect, but is shorter.

If the CD command is not followed by a valid path, it will simply display the current directory. In order to switch to a different directory, the CD command must be followed by a valid path.

After the command is executed, the name of the new current directory is displayed on the screen, unless the -N flag is included in the CD command after the path.

Syntax

CHDIR [<drive>:\] [<path>\] [-N]

ChDirCommand.png

Defaults

  1. Display the current directory drive and path.
  2. Change the current drive.
  3. Display the name of the new directory.

Parameters

The first optional parameter drive is the drive letter, which must be followed by a colon and a backslash. The results of this parameter depend upon whether or not it is followed by the path parameter. When specified by itself, drive causes BR to change the current drive to the one specified.

The path optional parameter may be specified after the drive letter to indicate the sequence of directories you wish to use as the current directory path. Each directory name must be preceded with a backslash \. If no backslash is present at the beginning of the directory name series, BR automatically appends the newly specified path to the end of the current directory path.

When path is specified, BR changes the current directory on the specified drive, but it does not change the current drive. As an example, assume that the current drive at your workstation is drive C. If you enter the following command, BR will change the current drive to drive B:

CHDIR B:

However, if you enter the following command, BR will change the current subdirectory on drive B to \BR\DATA; yet the workstation will continue to access drive C:

CHDIR B:\BR\DATA

The -N option may be used to turn off the automatic display of the new directory. This can be useful with PROC NOECHO.

Comments and Examples

To display of the current directory, type CHDIR and press <ENTER>.

The following example sets the current drive to drive A:

CHDIR A:

If the current directory is \sales and you wish to change it to \sales\december, any of the following commands will work:

CHDIR \sales\december
CHDIR december
CHDIR /december

You can change the current directory by typing CHDIR, a space, and the parameters that specify the desired path (separate each parameter with a comma or a space). If the specified path does not begin with a backslash (indicating the root directory), the system automatically places the pre-existing current directory path before the path you specify.

BR automatically displays the name of the new current directory after the CHDIR command has been executed. If this is undesirable, the -N option may be used to turn the display off.

A valid path for the CD command may be:

  • an absolute path,
  • a relative path,
  • a backslash,
  • two dots

If you use the CD command with an invalid path (a path that does not exist, is misspelled, or otherwise incorrect), then you will get a 4152 error

Here are some more examples:

cd C:\BR\data\companies\ABC_company

In the example above, the CD command is used with an absolute path, in which the drive and the entire folder structure is included

cd data\companies

In the example above, CD command is used with a relative path, which does not include the drive and the entire folder structure. Instead, this command assumes that the current directory has a sub-directory named data, which in turn also has a sub-directory called companies.

cd \

In the example above, CD command is used with a backslash, which changes the current directory to the root of the current directory tree. So if your current directory is C:\BR\data\companies\ABC_company, then after the CD \ command is used, the current directory will become C:\

cd ..

In the example above, CD command is used with two dots, which changes the current directory to the parent of the current directory. So if your current directory is C:\BR\data\companies\ABC_company, then after the CD .. command is used, the current directory will become C:\BR\data\companies

cd ..\..

In the example above, CD command is used with acombination of two dots, a backslash, and two more dots, which changes the current directory to the parent of the parent of the current directory. So if your current directory is C:\BR\data\companies\ABC_company, then after the CD ..\.. command is used, the current directory will become C:\BR\data