Donald, The problem is that my "batch.m," as you call it, is just an SPM8 _batch engine_ batch script. That is, it just defines a bunch of "matlabbatch" stuff. Running it within matlab doesn't do anything; it has to be "loaded" and "run" by the SPM8 batch engine. That's the part I'm uncertain how to instantiate in matlab code. In other words, it's not batch code I wrote myself (calling functions spm_*.m); rather, it's "SPM8 batch engine" batch code. Best, S Stephen J. Fromm, PhD Contractor, NIMH/MAP (301) 451--9265 ________________________________________ From: MCLAREN, Donald [[log in to unmask]] Sent: Thursday, January 13, 2011 9:16 AM To: Fromm, Stephen (NIH/NIMH) [C] Cc: [log in to unmask] Subject: Re: [SPM] Batching the SPM8 batch engine? subjects={} Currpath=pwd; for ii=1:length(subjects) cd([currpath filesep subjects{ii}]); Batch.m End You don't need to load the m file. You can run Ur straight from the command line. On Thursday, January 13, 2011, Stephen J. Fromm <[log in to unmask]> wrote: > I want to do the following (pseudocode): > > loop over subjects s { > cd into directory of s > load *.m batch script > run batch script > } > > Is there a way to write a small wrapper script like that? > > Or is there a way to "concatenate" the batch scripts for each subject within the matlabbatch "language" itself, with "run" commands in between? > > TIA, > > S > -- Best Regards, Donald McLaren ================= D.G. McLaren, Ph.D. Postdoctoral Research Fellow, GRECC, Bedford VA Research Fellow, Department of Neurology, Massachusetts General Hospital and Harvard Medical School Office: (773) 406-2464 ===================== This e-mail contains CONFIDENTIAL INFORMATION which may contain PROTECTED HEALTHCARE INFORMATION and may also be LEGALLY PRIVILEGED and which is intended only for the use of the individual or entity named above. If the reader of the e-mail is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that you are in possession of confidential and privileged information. Any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this e-mail unintentionally, please immediately notify the sender via telephone at (773) 406-2464 or email.