CD Keyword (INSERT command)

The optional CD keyword can specify the directory containing the inserted file as the working directory, making it possible to use relative paths for file specifications within the inserted file. The keyword is followed by an equals sign (=) and one of the following alternatives:

NO. The working directory is not changed. This is the default if the CD keyword is omitted.

YES. The working directory is changed to the directory containing the inserted file. Subsequent relative paths in command file specifications are interpreted as being relative to the location of the inserted file.

The change in the working directory remains in effect until some other condition occurs that changes the working directory during the session, such as explicitly changing the working directory on another INSERT command with a CD keyword or a CD command that specifies a different directory (see CD).

The CD keyword has no effect on the relative directory location for SET command file specifications, including JOURNAL , CTEMPLATE, and TLOOK. File specifications on the SET command should include complete path information.

The original working directory can be preserved with the PRESERVE command and later restored with the RESTORE command, as in:

PRESERVE.
INSERT FILE=’/commands/examples/file1.sps’
  CD=YES.
INSERT FILE=’file2.sps’.
RESTORE.
  • PRESERVE retains the original working directory location.
  • The first INSERT command changes the working directory.
  • The second INSERT command will look for file2.sps in /commands/examples.
  • RESTORE resets the working directory to whatever it was prior to the first INSERT command.

For more information, see the PRESERVE and RESTORE commands.