Change Current Directory (CHGCURDIR)

The Change Current Directory (CHGCURDIR) command changes a specified directory to the current working directory. The current directory can be a directory, library, folder, or database file. The current directory is used to locate objects used by the commands.

This command can also be issued using the following alternative file system command names:

For more information about integrated file system commands, see the Integrated file system topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Restrictions:

Parameters

Keyword Description Choices Notes
DIR Directory Path name Required, Positional 1

Directory (DIR)

Specifies the path name of the directory that replaces the current working directory of the job.

This is a required parameter.

For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information.

Examples

Example 1: Changing a Current Directory

CHGCURDIR   DIR(/DIRECTORY2)

This command changes the current directory to the directory named DIRECTORY2.

Example 2: Changing a Current Directory to the Parent of the Current Directory

CHGCURDIR   DIR('..')

This command changes the current directory to the parent directory of the directory that contains the current directory before this command is run.

Error messages

*ESCAPE Messages

CPFA085
Home directory not found for user &1.
CPFA08E
More than one name matches pattern.
CPFA093
Name matching pattern not found.
CPFA09C
Not authorized to object. Object is &1.
CPFA09D
Error occurred in program &1.
CPFA0A1
An input or output error occurred.
CPFA0A3
Path name resolution causes looping.
CPFA0A7
Path name too long.
CPFA0A9
Object not found. Object is &1.
CPFA0AB
Operation failed for object. Object is &1.