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.
CD [, Directory] [, CURRENT=variable]
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) or to the directory specified by
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
| Note |
To change drives:
CD, 'C:'
To specify a full path:
CD, 'C:\MyData\January'
To change from the C:\MyData directory to the C:\MyData\January directory:
CD, 'January'
To go back up a directory, use "..". For example, if the current directory is C:\MyData\January, you could go up to the C:\MyData directory with the following command:
CD, '..'
If the current directory is C:\MyData\January, you could change to the C:\MyData\February directory with the following command:
CD, '..\February'
To specify a full path:
CD, '/home/data/'
To change to the january subdirectory of the current directory:
CD, 'january'
To go back up a directory, use "..". For example, if the current directory is /home/data/january, you could go up to the /home/data/ directory with the following command:
CD, '..'
If the current directory is /home/data/january, you could change to the /home/data/february directory with the following command:
CD, '../february'
Introduced: Pre 4.0