The spm12 manual describes how batch jobs can be used to automate processing and the batch interface even allows you to save batch and script as indicated below for an example batch test. References for the spm anatomy toolbox. Fyi i eventually came across the contrast manager like i said very new to spm and 1 just set up the right contrasts for one session and one subject 2 using replicate scale to expand that to the other within subject sessions saved the mat file and 3 finally in a for loop just replaced the matlabbatch 1 spm stats con spmmat 1 with each subject id.