# # numproc should be set to the number of cores you have # fname is the name of the file which holds the name of the volumes # e.g.: # image1.img # imagenpto.img # image-kw.txt # numproc = 8 fname = "imglist.txt" line = [i.strip() for i in open(fname).readlines()] lin = list() for i in range(len(line)): lin.append("recon-all -i %s -s case%d -all"%(line[i],i)) for i in range(1,numproc+1): print "(", for cmd in lin[(i-1)*len(lin)/numproc:i*len(lin)/numproc]: print "%s ;"%cmd, print ")&"