(* USE WITH CAUTION BECAUSE OLD CAPTIONS WILL BE OVERWRITTEN! *) (***** Change these lines *****) minyear=2000; maxyear=2000; minroll=114; maxroll=114; dir="e:\\public_html\\pictures\\archives"; (******************************) BeginPackage["takebetween`"] takebetween::usage = "If the string s mathes the pattern *s1*s2* then takebetween[s,s1,s2][[1]] is True and takebetween[s,s1,s2][[2]] is the string between s1 and s2, otherwise takebetween[s,s1,s2] is {False,{}}." Begin["`private`"] takebetween[s_String,s1_String,s2_String]:= If[StringMatchQ[s,"*"<>s1<>"*"<>s2<>"*",IgnoreCase->True], posit=StringPosition[s,s1,IgnoreCase->True]; drop1={1,posit[[1,2]]}; s12=StringDrop[s,drop1]; posit=StringPosition[s12,s2,IgnoreCase->True]; drop2={posit[[1,1]],StringLength[s12]}; s12=StringDrop[s12,drop2]; {True,s12},{False,{}}] End[] EndPackage[] Do[ (* year *) year=ToString[nyear]; Do[ (* roll *) roll=ToString[nroll]; dirroll=ToFileName[{dir,year,roll}]; If[SetDirectory[dirroll]!=StringDrop[dirroll,-1],Goto[1]]; browser0=ToFileName[dirroll,"browser0.htm"]; capt=ToFileName[dirroll,"captions.txt"]; Print[" ---------- ",capt]; data=ReadList[browser0,String]; mlines=Length[data]; oc=OpenWrite[capt,PageWidth->Infinity]; captnumb=""; Do[line=data[[nline]]; t=takebetween[line,"