MATLAB Function Reference |
Graphical Interface
As an alternative to the dir
function, use the Current Directory browser.
Syntax
Description
dir
lists the files in the current working directory. Results are not sorted, but presented in the order returned by the operating system.
dir name
lists the specified files. The name
argument can be a pathname, filename, or can include both. You can use absolute and relative pathnames and wildcards (*
).
files = dir('directory')
returns the list of files in the specified directory (or the current directory, if dirname
is not specified) to an m
-by-1
structure with the fields
name |
Filename |
date |
Modification date |
bytes |
Number of bytes allocated to the file |
isdir |
1 if name is a directory; 0 if not |
Remarks
On Windows, obtain a list of drives available using the DOS net use
command. In the Command Window, run
to return the results to the character array r
.
List Directory Contents
To view the contents of the matlab/audiovideo
directory, type
Using Wildcard and File Extension
To view the MAT files in your current working directory that include the term java
, type
MATLAB returns all filenames that match this specification:
Using Relative Pathname
To view the M-files in the MATLAB audiovideo
directory, type
Contents.m aviinfo.m render_fullaudiotoolbar.m audiodevinfo.m aviread.m sound.m audioplayerreg.m lin2mu.m soundsc.m audiorecorderreg.m mmcompinfo.m wavfinfo.m audiouniquename.m mmfileinfo.m wavplay.m aufinfo.m movie2avi.m wavread.m auread.m mu2lin.m wavrecord.m auwrite.m prefspanel.m wavwrite.m avifinfo.m render_basicaudiotoolbar.m
Returning File List to Structure
To return the list of files to the variable av_files
, type
MATLAB returns the information in a structure array.
Index into the structure to access a particular item. For example,
See Also
cd
, copyfile
, delete
, fileattrib
, filebrowser
, fileparts
, genpath
, isdir
,
ls
, matlabroot
, mkdir
, mfilename
, movefile
, rmdir
, type
, what
diff | dir (ftp) |
© 1994-2005 The MathWorks, Inc.