Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

CD


Syntax | Arguments | Keywords | Examples | Version History | See Also

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.

Syntax

CD [, Directory] [, CURRENT=variable]

Arguments

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) or to the directory specified by !DIR (Windows). If this argument is not specified, the working directory is not changed.

Keywords

CURRENT

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.

Examples

Windows

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' 
Unix

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' 

Version History

Introduced: Pre 4.0

See Also

PUSHD, POPD


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]