SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\KBH"];
<< "../../2013-03/CellExport.m";
SetOptions[CellExport, ExportFormat -> ".png", PageWidth -> 6.25*0.24/0.18];

SourceNotebook = Get["C:\\drorbn\\AcademicPensieve\\Projects\\KBH\\KBH.nb"];

TagProperties["BorromeanTrees"] = {PageWidth -> 15, CellFilter -> Last};
TagProperties["BorromeanWheels"] = {PageWidth -> 15, CellFilter -> Last};
TagProperties["TheTrivialBalloon"] = {PageWidth -> 2, CellFilter -> Last};
TagProperties["ExampleZeta"] = {PageWidth -> 4.5*0.24/0.18};
DialogTags={"BCHDemo1", "BCHDemo2", "Testing_tm", "Testing_hm", "taction", "haction", "TestingConjugationRelation", "817-1","817-2","817-3", "Borromean1","Borromean2","Borromean3", "eab", "JBCH"};

tags=Cases[SourceNotebook, (CellTags->tag_) :> tag, Infinity ] // Union;
Print[tags];
files=Flatten[Table[
If[MemberQ[DialogTags, tag],
{
CellExport[SourceNotebook, tag, CellFilter -> First, ExportBaseFilename -> "Human-"<>tag],
CellExport[SourceNotebook, tag, CellFilter -> Rest, ExportBaseFilename -> "Machine-"<>tag]
},
CellExport[SourceNotebook, tag]
],
{tag, tags}]];
listing=OpenWrite["listing.txt"];
WriteString[listing, #<>"\n"]& /@ files;
Close[listing];
do="/bin/cp -f pensieve/foo.png figs
chmod -x figs/foo.png
sam2p figs/foo.png figs/foo.eps
";
pp=OpenWrite["postprocess.csh", BinaryFormat -> True];
BinaryWrite[pp, StringReplace[do, "foo"->StringDrop[#,-4]]]& /@ files;
Close[pp];
Print["Resizing BorromeanTrees and BorromeanWheels..."];
Export[#, ImageResize[Import[#], 1200]]& /@ {"BorromeanTrees.png", "BorromeanWheels.png"};
(#->Import[#])& /@ files

TagProperties["BCHDemo2"] = {ExportFormat -> ".pdf"};
CellExport[SourceNotebook, "BCHDemo2"]

TagProperties["ExampleZeta"] = {PageWidth -> 4.5*0.24/0.18};CellExport[SourceNotebook, "ExampleZeta"]

CellExport[SourceNotebook, "TheTrivialBalloon"]

TagProperties["MMADefs"] = {ExportFormat -> ".pdf"};
CellExport[SourceNotebook, "MMADefs"]