par;
fprintf('\r%-40s\n','batch deleting intermediate files ')
oldpath=pwd;
% get the subdirectories in the main directory
for sb = 1:length(PAR.subjects) % for each subject
    %go get the sessions
    for ses=1:length(PAR.sess)

                   
        %now get all images to reset orientation
        for c=1:ncond
            cd(PAR.condirs{sb,c});
            delete a*.nii
            delete ra*
            delete d_comp.dat
            delete EPI_noskull.nii
            delete flt*
            delete mask_bet.nii
            delete mean*
            delete rbk*
            delete SEN*
            delete sflt*
            delete tSTD*
            delete spm_*.ps
            delete *.mat
            delete rp*.txt
            delete real*.jpg
        end
        cd( PAR.structdir{sb})
        delete c*.nii
        delete y*.nii
        delete iy*.nii
        delete rc*.nii
        delete t1_noskull.nii
        delete *.mat
    end
end
