ChDir

From BR Wiki
Revision as of 17:34, 15 December 2011 by Mikhail.zheleznov (talk | contribs)
Jump to navigation Jump to 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

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 parameter drive is the drive letter, which must be followed by a colon. 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 default drive to the one specified.

The path parameter may be specified after the drive letter to indicate the sequence of directories you wish to use as the default 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 default directory path.

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

CHDIR B:

But if you enter the following command, BR will change the default subdirectory on drive B to \\BR\\DATA; the workstation will continue to access drive C, however:

CHDIR B:\\BR\\DATA

The second route through the CHDIR syntax is the System/23-format equivalent to the top route. /Subdirectory/ is the name of a subdirectory that is to become the new default; the forward slashes indicate System/23 format. Drive-num is a System/23 drive number which BR translates into a drive letter according to the information in the BRConfig.sys file's S/23-DRIVES specification. When this parameter is specified without a preceding subdirectory name, BR changes the current drive to the drive specified. When a drive-num is preceded by a subdirectory name, BR changes the default directory on the specified drive to the named subdirectory, but it does not change the current drive.

The third and fourth routes through the CHDIR syntax allow you to specify either the path or the /subdirectory parameters to change the default directory on the default drive. Path is the sequence of directories that is to become the default. When it is not preceded by a backslash, BR automatically appends the specification to the end of the current default directory path. /Subdirectory is the System/23-format equivalent to the path parameter.

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

For a display of the current default directory, type CHDIR and press <ENTER>.
The following example sets the default drive to drive A:

CHDIR A:

If the current default 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 default 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 default directory path before the path you specify.
BR automatically displays the name of the new default 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

Technical Considerations

When CD -N is specified, the -N parameter will be overridden by the request for a display of the current directory.