wolffd@0: function mkdirKPM(dname) wolffd@0: % function mkdirKPM(dname) wolffd@0: % If directory does not exist, make it wolffd@0: % wolffd@0: % mkdirKPM('foo\bar\baz') makes subdirectories bar and baz wolffd@0: % mkdirKPM('foo\bar\baz.txt') makes subdirectories bar wolffd@0: wolffd@0: % convert foo\bar\baz to pathstr=foo\bar, name=baz wolffd@0: % convert foo\bar\baz.txt to pathstr=foo\bar, name=baz wolffd@0: [pathstr, name, ext, versn] = fileparts(dname); wolffd@0: if ~isempty(ext) % we stripped off something after final period wolffd@0: % convert foo\bar to pathstr=foo, name=bar wolffd@0: % convert foo\bar.bad to pathstr=foo, name=bar.bad wolffd@0: [pathstr, name, ext, versn] = fileparts(pathstr); wolffd@0: name = sprintf('%s%s', name, ext); % in case there is a period in the directory name wolffd@0: end wolffd@0: wolffd@0: dname = fullfile(pathstr, name); wolffd@0: if ~exist(dname, 'dir') wolffd@0: %fprintf('mkdirKPM: making %s, %s \n', pathstr, name); wolffd@0: mkdir(pathstr, name) wolffd@0: else wolffd@0: %fprintf('mkdirKPM: %s already exists\n', dname) wolffd@0: end