% WARNING: call_cleanup.m deletes all generated output files from the working
% directory, including .eps, .pdf, .tex, .log, .mat, and related files, as well as
% all Dynare-generated files and +model_* and model_* folders. This action is
% irreversible. readme.tex, readme.pdf, and extra_parameters.mat are preserved.
% Run only to start fresh. It will erase all figures and tables produced by the
% replication scripts.



delete *.eps
delete *.asv
delete *.dvi
delete *.aux

delete *_static.m
% Delete .mat files, preserving extra_parameters.mat
mat_files = dir('*.mat');
for i = 1:length(mat_files)
    if ~strcmp(mat_files(i).name, 'extra_parameters.mat')
        delete(mat_files(i).name);
    end
end
delete *_dynamic.m
delete *_set_auxiliary_variables.m
delete *.log
delete *.*latexmk
delete *.fls
delete *.gz

!rm -r +rbcb*

% Delete plain model_* directories created by Dynare at parse time.
% Filter to directories only so that .mod source files are never at risk.
model_dirs = dir('rbcb*');
model_dirs = model_dirs([model_dirs.isdir]);
for i = 1:length(model_dirs)
    rmdir(model_dirs(i).name, 's');
end

