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