|
IDL Reference Guide: Procedures and Functions |
|
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.
IDL's default current working directory depends on the platform and method used to invoke IDL:
idl), the default current working directory is the directory from which IDL was started.
idlde), the default current working directory is controlled by the value of the IDL_MDE_START_DIR preference.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 !DIR (Windows). 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
| Note The return value of the CURRENT keyword does not include a directory separator at the end of the string. |
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: