IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
getfiles.m
Go to the documentation of this file.
1 %>@file
2 %>@brief File list getter (not recursive)
3 %> @ingroup ioio
4 %>
5 %> @param wild ='*'. E.g. '*.mat'
6 %> @param patt_match (regular expression) If specified, directories will have to match this pattern
7 %> @param patt_exclude (regular expression) If specified, directories will have NOT TO match this pattern
8 %> @return list
9 function names = getfiles(wild, patt_match, patt_exclude)
10 
11 if nargin < 1
12  wild = '*';
13 end;
14 if nargin < 2
15  patt_match = [];
16 end;
17 if nargin < 3
18  patt_exclude = [];
19 end;
20 flag_match = ~isempty(patt_match);
21 flag_exclude = ~isempty(patt_exclude);
22 
23 d = dir(wild);
24 names = {d.name};
25 
26 if flag_match
27  names = names(cellfun(@(x) ~isempty(x), regexp(names, patt_match, 'start')));
28 end;
29 if flag_exclude
30  names = names(cellfun(@isempty, regexp(names, patt_exclude, 'start')));
31 end;
function getfiles(in wild, in patt_match, in patt_exclude)