F = rdir(NAME) returns a cell array of file names matching NAME.
NAME may be a cell array of strings, and may contain cascading
pathnames separated by '/' (or '\') followed by a filename. Wildcards
(*) may be used both in the final filename, as in DIR, but also in the
intermediate pathnames. For example, F=rdir('mydir*/*.m') returns all
the M-Files contained in each directory that begins with 'mydir'.
File number indexing: Brackets [] may be used in the file or directory
names for convenient number indexing. If the input string is in the form
'PP[RANGE]SS', all files or directories matching 'PP0000nSS' will be
returned, where 'PP' and 'SS' are prefix and suffix substrings, and n
is an index lying in the range RANGE (paded with 5 zeros by default).
RANGE is a vector, that can be in the form [N1 N2 N3..], or START:END,
or START:STEP:END, or any other MATLAB valid syntax.
Use 'PP[RANGE,NZ]SS') to specify the number of zeros to pad the index
string (NZ=5 by default). For example, 'B[1:4,2].v*' gives
{'B01.v*','B02.v*','B03.v*','B04.v*'}.
Use 'PP[RANGE,NZ.NP]SS' to specify the number of digits NP after the
decimal point (NP=0 by default). For example, 'dt=[1:0.5:2,2.3]s' gives
{'dt=1.000s','dt=1.500s','dt=2.000s'}.
If the input string has more than one bracket pair [], rdir is
called recursively for each pair. For example, 'B[1:4,2]_[1 2,1]'
gives {'B01_1','B01_2','B02_1','B02_2','B03_1','B03_2','B04_1','B04_2'}
rdir file_name or rdir('file_name') displays the result.
F = rdir(NAME,'fileonly') only returns file names.
F = rdir(NAME,'dironly') only returns directory names, but does not
list their content.
F = rdir(NAME,'filedir') returns both files and directories (as DIR),
by default.
(Note that, when options 'dironly' or 'filedir' are used, the
fictitious directories '.' (current) and '..' (parent) are not
returned, contrarily to DIR).
Examples
F = rdir('set*/B[1:8,2].v*') returns the file names matching
'B01.v*' to 'B08.*' in each directory matching 'set*'.
F = rdir('set[1 2 3]*/*/B01.vec') returns the file name 'B01.vec',
if present, in all the subdirectories of each directory matching
'set1*', 'set2*', 'set3*'.
F = rdir('Myfiles_dt=[1:0.5:2,5.2]s.*') returns the file names
'Myfiles_dt=01.00s.*', 'Myfiles_dt=01.50s.*', 'Myfiles_dt=02.00s.*'
See Also
DIR, lsw, cdw.