The CD procedure is used to set and/or change the current working directory. This routine changes the working directory for the IDL session and any child processes started from IDL during that session after the directory change is made. Under Unix, CD does not affect the working directory of the process that started IDL. The PUSHD, POPD, and PRINTD procedures provide a convenient interface to CD.

Calling Sequence

CD [, Directory]



A scalar string specifying the path of the new working directory. If Directory is specified as a null string, the working directory is changed to the user's home directory (Unix and VMS) or to the directory specified by !DIR (Windows and Macintosh OS). If this argument is not specified, the working directory is not changed.



If CURRENT is present, it specifies a named variable into which the current working directory is stored as a scalar string. The returned directory is the working directory before the directory is changed. Thus, you can obtain the current working directory and change it in a single statement:

CD, new_dir, CURRENT=old_dir


Under Unix, to change the working directory to the "data" subdirectory of the current directory, enter:

CD, 'data'

Under VMS, you could use:

CD, '[.data]'

See Also