It’s taken a bit of tweaking but I’ve finally put together a simple script which archives and publishes in one command.

The Problem

Last post, I mentioned having three different scripts to effectively publish:

  • (the first script I wrote to push to Scriptogram from the console)
  • (a script I wrote to create the metadata Scriptogram needed automatically)
  • (a more recent script to keep my drafts folder clear of published material)

These had to be executed in a certain order (2, 1, 3 as it turns out since was dependent on

Furthermore, I still had to tweak the files as I went. The script was written so that it required the first level-1 header in the file to provide the title of the post (Scriptogram takes this as a metadata field), whereas didn’t need the level-1 header at all. In fact, as it was, I had to manually strip out the header, publish with before putting it back in for I wanted to do away with this fiddliness.

The Solution

I got rid of and integrated that into my file.

That left me with only two files so I had to create another one to make up for it (I’m only half-serious).

I wrote to effectively determine the order the other two scripts should be run in and to save myself from typing two commands. At the moment, it’s a simple as this:

## Make folder definitive by moving out of `drafts` and into `archive`.

	pieceref=$(./ $1)

## Use reference for relevant piece to push out to Scriptogram.

	./ $pieceref

You may also notice that it takes an output from as a variable and uses it as an argument for This is because I silenced other messages from and had it echo only the new filename of the now-archived piece.

This is effectively like a sign-off which provides a single reference to the relevant content. I then use that reference for a now adapted to push straight from the archive to my blog – which happens to be on Scriptogram.

As I write other scripts for other possible blogging platforms I simply add the scripts to this file using the same archived piece reference. In this way, I can theoretically push out to multiple channels and keep my own repository channel-neutral.

What next?

At some point, I see myself relegating all Scriptogram specific scripts and data files to a Scriptogram specific folder so that I can start to explore and review other platforms without any dependencies. I might also need to build in some error-checking.

In the short-term however I hope to use this work on tying up and making the publish consistent as a springboard into issues like cross-linking and image-referencing. And from there on into less self-referential posts.

I also need to come up with a simple way of republishing a post, with or without a new date and time. At the moment, the scripts act as if typos and the like won’t ever be a problem.