-
Notifications
You must be signed in to change notification settings - Fork 1
/
locateTCfiles.m
31 lines (26 loc) · 988 Bytes
/
locateTCfiles.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
function filenames = locateTCfiles(baseFolder)
% Function recursively searches baseFolder and all subfolders for _tc
% files and returns them as a cell string.
if ~isdir(baseFolder) && ~isempty(strfind(baseFolder,'_tc')) && ...
~isempty(strfind(baseFolder,'.dat'))
filenames = baseFolder;
else
filenames = {};
listing = dir(baseFolder);
for i = 3:length(listing)
if listing(i).isdir
filenames = [filenames, ...
locateTCfiles(fullfile(baseFolder,listing(i).name))]; ...
%#ok<AGROW>
else
if ~isempty(strfind(listing(i).name, '_tc')) && ...
~isempty(strfind(listing(i).name, '.dat')) && ...
~isempty(strfind({listing.name}, ...
strrep(listing(i).name,'_tc','')))
filenames = [filenames, ...
fullfile(baseFolder, listing(i).name)]; %#ok<AGROW>
end
end
end
end
end