function was_created = CheckCreateDirs(dir_name, verbatim)
% Checks dir_name{1:N} to see if each one exists. If it doesn't it is
% created. If it exists, the files inside may be overwritten. 
%
% To perform this function on a single folder, use:
% CheckCreateDirs({dir_name})
% where dir_name is a path string.
if nargin == 1
    verbatim = 1;
end

N = length(dir_name);
if verbatim 
    disp('      Setting up output directory structure...')
end
for n = 1:N
    if exist(dir_name{n}, 'dir')~=7 %true if dir does not exist
        display_message = sprintf('         creating dir %s', dir_name{n});
        mkdir(dir_name{n});
        if verbatim, disp(display_message); end
        was_created = true;
    else
        display_message1 = '         the write directory:';
        display_message2= '         already exists... rewriting files in this directory';
        if verbatim 
            disp(display_message1); 
            disp(sprintf('            %s', dir_name{n}));
            disp(display_message2); 
        end
        was_created = false;
    end
end