Directory Commands



To change the current or working directory, use "Change dir" from the GUI environment, or setwd(...) from the command line.

Determine the current directory using the command getwd().

List files in the current directory using the command dir('.').



The GUI command for changing directories is available in the file pull-down menu :

From the command line, one can change the directory using the setwd(...) command. For example,

> setwd('Z:/Samples');

or

> setwd('Z:\\Samples');

if one prefers using double backslashes for file separators.

The command can also take relative path specifications e.g. '../MoreSamples' to mean a directory MoreSamples that is a subdirectory of the parent to the current directory.

Original Documentation: ls, dir, setwd, getwd

Samples

  dir('.')                        # list the files in the current directory 

  dir(getwd())                    # list the files in the working directory 

  getwd()                         # get the current (working) directory

  setwd('Z:/Samples')             # set the working directory to Z:\Samples

  setwd('..')                     # set the working directory to parent of current directory

UCLA Mathematics Department ©2000