annotate toolboxes/FullBNT-1.0.7/KPMtools/mkdirKPM.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function mkdirKPM(dname)
wolffd@0 2 % function mkdirKPM(dname)
wolffd@0 3 % If directory does not exist, make it
wolffd@0 4 %
wolffd@0 5 % mkdirKPM('foo\bar\baz') makes subdirectories bar and baz
wolffd@0 6 % mkdirKPM('foo\bar\baz.txt') makes subdirectories bar
wolffd@0 7
wolffd@0 8 % convert foo\bar\baz to pathstr=foo\bar, name=baz
wolffd@0 9 % convert foo\bar\baz.txt to pathstr=foo\bar, name=baz
wolffd@0 10 [pathstr, name, ext, versn] = fileparts(dname);
wolffd@0 11 if ~isempty(ext) % we stripped off something after final period
wolffd@0 12 % convert foo\bar to pathstr=foo, name=bar
wolffd@0 13 % convert foo\bar.bad to pathstr=foo, name=bar.bad
wolffd@0 14 [pathstr, name, ext, versn] = fileparts(pathstr);
wolffd@0 15 name = sprintf('%s%s', name, ext); % in case there is a period in the directory name
wolffd@0 16 end
wolffd@0 17
wolffd@0 18 dname = fullfile(pathstr, name);
wolffd@0 19 if ~exist(dname, 'dir')
wolffd@0 20 %fprintf('mkdirKPM: making %s, %s \n', pathstr, name);
wolffd@0 21 mkdir(pathstr, name)
wolffd@0 22 else
wolffd@0 23 %fprintf('mkdirKPM: %s already exists\n', dname)
wolffd@0 24 end