MRmkdirIF

Helpful when one needs to create directories programatically. This checks if a directory of the given name exists, if it does not, create it otherwise do nothing.

 

function dir = MRmkdirIF(dir)

%

%    mkdirIF(dir)   – create a directory at current pwd if it does not exist

%

%    dir            – name of directory to create

 

if dir(end) ~= ‘/’

dir = [dir ‘/’];

end

if (exist(dir, ‘dir’) == 0)

mkdir(dir);

end

end

MRmkdirIF.m