Please enable JavaScript to view this site.

Knowledge Base

Navigation: Scripting Language > System

ls

We've made some changes. Use 'Ctrl-F5' to clear your browser cache.
Scroll Prev Top Next More

Lists files in a directory. Files other than Lumerical project files are also listed.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

out = dir;

out = ls;

The output is a string.

Use ?dir; to write the value to the screen.

out = dir("directory");

out = ls("directory");

Lists the files in the specified directory. For example, ?ls("C:\Downloads");

 

Example

Uses the splitstring command to get the contents of a directory in a cell (ie. string) array. Then loop through the array looking for all FDTD Solutions project files (.fsp).

files = splitstring(dir,endl);        # directory contents in a cell (string) array

for(i=1:length(files)) {           # loop over all files

 if (findstring(files{i},"fsp") != -1) {  # look for 'fsp' files

  if (fileexists(files{i})) {       # check if the file exists (ie. it's a file and not a directory)

   ?files{i};               # output file name

   load(files{i});            # load file

  }

 }

}

 

See Also

System level, load, splitstring

Copyright Lumerical Inc. | Privacy | Site Map