I have what I believe is a simple programming question. I have a text file that looks like:
mol 1 G:\stereo01.hin
block text
...
...
...
endmol 1
However, I would like a file that repeats this entire block of text several times over. The lines of text in the middle remain the same for each loop, but I'd like it if the numbers in bold in the above text went up sequentially with each loop of the text. So what I'm looking for is
Prompt how many copies (save as n)
Create a new file that is
mol 1 G:\stereo01.hin
block text
endmol1
mol 2 G:\stereo02.hin
block text
endmol2
...
mol "n" G:\stereo"n".hin
block text
endmol"n"
Thanks in advance for your help! 
bash:
cp $origfile $newfile
for i in $( seq 2 $n ); do
sed -e "s/endmol 1/endmol$i/" -e "s/mol 1 G:\\\\stereo01/mol $i G:\stereo$(printf %02d $i)/" $origfile >> $newfile
done
I'm assuming that you can initialise the variables with the names of the original file, the new file that you are making and the number of sections you need.
I'm assuming (more importantly) that the "block text" cannot contain the text (i.e. "endmol 1" etc) I'm using as matching regexps. If it can, then you would need to make those regexps more robust.
That works fantastically, thanks a lot!