-
Notifications
You must be signed in to change notification settings - Fork 0
/
rls.m
39 lines (34 loc) · 751 Bytes
/
rls.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
function fileList = rls(arg, relPathBool)
%% rls
% Author: Erik Roberts
%
% Purpose: recursive file list using unix 'find'
%
% Usage: fileList = rls(arg)
% fileList = rls(arg, relPathBool)
%
% Inputs:
% arg: argument string to unix 'find' program
% relPathBool: logical whether to convert to relative paths
% default inputs
if nargin == 0
arg = [];
end
if nargin < 2
relPathBool = false;
end
if isunix || ismac
[~, fileList] = system(['find ' arg]);
else
fprintf('This function only works on linux, mac, and unix systems.\n')
return
end
% convert from char array to cell array
fileList = strsplit(fileList);
if isempty(fileList{end})
fileList(end) = [];
end
if relPathBool
fileList = regexprep(fileList, pwd, '');
end
end