Skip to content

Instantly share code, notes, and snippets.

@scripting
Created December 22, 2021 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scripting/2531341ed9e2426b1d11848b76905f7c to your computer and use it in GitHub Desktop.
Save scripting/2531341ed9e2426b1d11848b76905f7c to your computer and use it in GitHub Desktop.
A script that runs in Frontier to convert the big OPML archive to the current form.
on convertOpmlArchive () {
«Changes
«12/21/21; 3:25:01 PM by DW
«This script converts the archive from the form I found it in on scripting.com, to the form used in the GitHub-based archive.
«Input: One OPML file for each day.
«Output: One OPML file for each month, broken down by day inside the outline.
«All other files, indexes and sitemaps, garbage left around by crappy server software, were not passed through.
local (sourcefolder = "Macintosh HD:Users:davewiner:tmp:opmlArchive:");
local (destfolder = "Macintosh HD:Users:davewiner:tmp:opmlArchive2:");
fileloop (fyear in sourcefolder) {
if file.isfolder (fyear) {
local (yearnum = number (file.filefrompath (fyear) - ":"));
fileloop (fmonth in fyear) {
if file.isfolder (fmonth) {
local (monthnum = number (file.filefrompath (fmonth) - ":"));
local (monthname = date.monthToString (monthnum));
local (lo);
new (outlinetype, @lo);
target.set (@lo);
edit (@lo);
for (i = date.daysinmonth (monthnum) downto 1) {
local (fday = fmonth + string.padwithzeros (i, 2) + ".opml");
if file.exists (fday) {
local (opmltext = file.readwholefile (fday), dayoutline);
op.xmltooutline (opmltext, @dayoutline);
local (daynum = number (file.filefrompath (fday) - ".opml"));
local (daystring = monthname + " " + daynum);
op.insert (daystring, down);
op.attributes.setone ("created", date.netstandardstring (date.set (daynum, monthnum, yearnum, 0, 0, 1)));
op.insertoutline (@dayoutline, right);
op.collapse ()}};
op.firstsummit ();
op.setlinetext (monthname + " " + yearnum);
op.attributes.setone ("created", date.netstandardstring (date.set (1, monthnum, yearnum, 0, 0, 2)));
op.demote ();
window.settitle (@lo, "Scripting News");
window.attributes.setOne ("flPublic", true, @lo);
local (opmltext = op.outlinetoxml (@lo));
local (fmonth = destfolder + yearnum + ":" + string.padwithzeros (monthnum, 2) + ".opml");
file.surefilepath (fmonth);
file.writewholefile (fmonth, opmltext)}}}}};
«fileloop (f in sourcefolder, infinity) //remove garbage files
«local (fname = file.filefrompath (f))
«if fname endswith "$folder$"
«file.delete (f)
bundle { //test code
convertOpmlArchive ()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment