spm_mkdir.m 975 B

123456789101112131415161718192021222324252627282930313233
  1. function sts = spm_mkdir(varargin)
  2. % Make new directory trees
  3. % FORMAT sts = spm_mkdir(dir,...)
  4. % dir - character array, or cell array of strings
  5. %
  6. % sts - true if all directories were successfully created or already
  7. % existing, false otherwise.
  8. %__________________________________________________________________________
  9. % Copyright (C) 2017 Wellcome Trust Centre for Neuroimaging
  10. % Guillaume Flandin
  11. % $Id: spm_mkdir.m 7088 2017-06-01 16:18:44Z guillaume $
  12. sts = true;
  13. if nargin > 0
  14. d1 = cellstr(varargin{1});
  15. for i=1:numel(d1)
  16. if ~exist(spm_select('cpath',d1{i}),'dir')
  17. status = mkdir(d1{i});
  18. sts = sts & status;
  19. end
  20. if nargin > 1
  21. d2 = cellstr(varargin{2});
  22. for j=1:numel(d2)
  23. status = spm_mkdir(fullfile(d1{i},d2{j}),varargin{3:end});
  24. sts = sts & status;
  25. end
  26. end
  27. end
  28. else
  29. error('Not enough input arguments.');
  30. end