Pensieve header: Make the snip files in Snips/.

Exit[];

MakeSnips["GDOCompositions", DialogTags->{"RandomM", "LeftAssociation", "Associativity"}]

Prolog

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects/DPG"];
SetOptions[$FrontEndSession,PrintingStyleEnvironment->"Working"];

“WinSort” from https://mathematica.stackexchange.com/questions/10619/sort-strings-by-natural-ordering:

WinSort[names_List]:=names[[Ordering[Characters[names]]]];

CellExport

(Following pensieve://Talks/Matemale-1804/CellExport.nb)

ConditionalExport[fname_String, rest___] := Module[{temp, exists},
temp="ConditionalExportTemporary"<>"."<>FileExtension[fname];
exists=FileExistsQ[fname];
Export[temp, rest];
If[exists && FileByteCount[fname]===FileByteCount[temp],
DeleteFile[temp],
(* else *) (*Print["Exporting "<>fname<>"..."];*)
If[exists, DeleteFile[fname]];
RenameFile[temp, fname]
];
fname
];

TagProperties[_] := {};
Options[CellExport] = {
PageWidth -> 6, CellFilter -> Identity, ExportBaseFilename -> Automatic, ExportFormat -> ".pdf", ExportOptions -> {}, Split -> False };
CellExport[tag_String, opts___Rule] := CellExport[NotebookGet[EvaluationNotebook[]],tag, opts];
CellExport[nb_Notebook, tag_String] := CellExport[nb, tag, TagProperties[tag]];
CellExport[nb_Notebook, tag_String, opts___Rule] := Module[
{cells,p, cell,pwunit=108,
filename = ExportBaseFilename /.{opts}/.Options[CellExport]/. Automatic -> tag,
format=ExportFormat/.{opts}/.Options[CellExport],
filter=CellFilter/.{opts}/.Options[CellExport],
split=Split/.{opts}/.Options[CellExport],
pagewidth=PageWidth/.{opts}/.Options[CellExport],
exportoptions=ExportOptions/.{opts}/.Options[CellExport]
},
Print["exporting ",tag," with ", {opts},"/.",Options[CellExport],"..."];
cells={Table[nb[[Sequence@@p[[1;;-2]]]],
{p,Position[nb, CellTags->tag]}
] // filter}//Flatten;
If[split,
If[Length[cells]≥1,
If[Length[cells]==1,
cells=Append[First[cells], PageWidth ->  pwunit pagewidth],
cells=Cell[CellGroup[cells], PageWidth ->  pwunit pagewidth]
];
ConditionalExport[filename<>format,cells,ImageResolution -> 300,exportoptions]
],
k=0;
Table[
++k;
ConditionalExport[
filename<>"-"<>ToString[k]<>format,
Append[cell, PageWidth ->  pwunit pagewidth],ImageResolution -> 300,exportoptions],
{cell, cells}
]
]
];

Snips

MakeSnips[nb_,opts___Rule] := (
{
dt=DialogTags/.{opts}/.DialogTags->{},
force=Force/.{opts}/.Force->False
};
If[FileType["Snips/"<>nb]===None, CreateDirectory["Snips/"<>nb]];
If[force∨FileType["Snips/"<>nb<>"/Verification.txt"]===None∨AbsoluteTime@FileDate["Snips/"<>nb<>"/Verification.txt"]<AbsoluteTime@FileDate[nb<>".nb"],
If[Head[$FrontEnd]===FrontEndObject,
SetOptions[CellExport, ExportFormat -> ".pdf", Split -> True, PageWidth -> 7.12, ExportOptions -> {ImageSize->Scaled[0.5]}],
SetOptions[CellExport, ExportFormat -> ".pdf", Split -> True, PageWidth -> 7.12]
];
SourceNotebook =NotebookGet@NotebookOpen[Directory[]<>"/"<>nb<>".nb"];
tags=Cases[SourceNotebook, (CellTags->tag_) :> tag, Infinity ] // Union;
files=Reap[Flatten[Table[
Which[
tag=="817", { (* this is only left here as a demo for how to make an exception *)
Sow@CellExport[SourceNotebook, "817", CellFilter -> First, ExportBaseFilename -> "Snips/"<>nb<>"/817-In"],
Sow@CellExport[SourceNotebook, "817", CellFilter -> Rest, ExportBaseFilename -> "Snips/"<>nb<>"/817-Out", PageWidth -> 5.5*0.24/0.16]
},
MemberQ[dt, tag], {
Sow@CellExport[SourceNotebook, tag, CellFilter -> First, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag<>"-In"],
Sow@CellExport[SourceNotebook, tag, CellFilter -> Rest, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag<>"-Out"]
},
True, Sow@CellExport[SourceNotebook, tag, ExportBaseFilename -> "Snips/"<>nb<>"/"<>tag]
],
{tag, tags}]]];
PutAppend[DateString[], "Snips/"<>nb<>"/Verification.txt"];
files=Flatten[files];
(*DeleteFile /@ Complement[StringReplace["\\"->"/"]/@FileNames["Snips/"<>nb<>"/*.pdf"], files];*)
WinSort@Union[files],
(*Else*)
WinSort@FileNames["Snips/"<>nb<>"/*.pdf"]
]
)