-
Notifications
You must be signed in to change notification settings - Fork 42
/
AddSubDirsToPath.m
66 lines (52 loc) · 1.41 KB
/
AddSubDirsToPath.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function AddSubDirsToPath
%------------------------------------------------------------------------
% Add all sub-directories of the current directory to your MATLAB path.
% Does not add SVN or CVS folders, or any folders that begin with "."
%------------------------------------------------------------------------
% Form:
% AddSubDirsToPath
%------------------------------------------------------------------------
%
% ------
% Inputs
% ------
% None
%
% -------
% Outputs
% -------
% None
%
%------------------------------------------------------------------------
%------------------------------------------------------------------------
% Copyright 2009 Princeton Satellite Systems, Inc.
% All rights reserved.
%------------------------------------------------------------------------
topDir = pwd;
cd( topDir )
p = cd;
path( fullfile(p,''), path );
s = dir;
np = {};
for k = 1:length(s)
if( s(k).isdir && ~strcmp( '.', s(k).name(1) ) )
z = fullfile( p, s(k).name, '' );
np = AddDirectoryToPath( z, np );
end
end
if( ~isempty(np) )
addpath(np{:});
end
cd( topDir );
msgbox('Paths Set!')
function np = AddDirectoryToPath( p, np )
s = dir( p );
np{end+1} = p;
for k = 1:length(s)
if( s(k).isdir & ~strcmp( '.', s(k).name(1) ) )
z = fullfile( p, s(k).name, '' );
if( isempty(findstr( '@', z )) )
np = AddDirectoryToPath( z, np );
end
end
end