-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathfindFiles_xcl.m
42 lines (39 loc) · 986 Bytes
/
findFiles_xcl.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% This function will find all subfolders of a directory
function files = findFiles_xcl(rootdir, extension, relative_path)
% Author: Xu Chenglin (NTU, Singapore)
% Date: 3 Dec 2016
% Format: 1 Nov 2017
if nargin<3
relative_path = 0;
end
if nargin<2
extension = '*';
end
[list ISDIR]= my_dir(rootdir);
files = {};
accept_all_extension = 0;
if extension == '*'
accept_all_extension = 1;
end
for i=1:length(list)
tmp = [rootdir '/' list{i}];
if ISDIR(i)==1
subfiles = findFiles_xcl(tmp, extension, 0);
files = [files subfiles];
else
if relative_path==1
currFile = list{i};
else
currFile = [rootdir '/' list{i}];
end
if accept_all_extension
files{end+1} = currFile;
else
if strcmpi(list{i}(end-length(extension)+1:end), extension) == 0
continue;
else
files{end+1} = currFile;
end
end
end
end