Automating Blog Posts with AppleScript v2

July 1, 2016
Category: TIL
Tags: AppleScript, Resources, and Apps

I decided that my earlier attempt at automating creation of these TIL posts was still too manual. This one is better!

What it does:

  1. Creates a markdown file with today’s date and my specified string at the title.
  2. Launches Coda in the foreground and goes to my preset Jekyll blog site (cagrimmett.com)
  3. Opens the file it just created in the front window.
  4. Expands the previous TextExpander snippet I created as a template for these TIL posts.

The Script

%filltop%

on textexpander(abbreviation)	
do shell script "cd ~/Projects/cagrimmett-com/_posts/til; touch %snippet:fname%"

tell application "Coda 2"
	activate window
	get site 6 of application "Coda 2"
	tell window 1
		connect to site 6 of application "Coda 2"
			open "Macintosh HD:Users:CAG:Projects:cagrimmett-com:_posts:til:%snippet:fname%"
	end tell
end tell
tell application "TextExpander"
	expand abbreviation ";tem"
end tell

end textexpander

Here are what the other two snippets fill in:

fname- I had to make this a snippet instead of putting it in directly because in the filename creation string TextExpander didn’t recognize the date string. If you nest it inside another snippet, it works just fine.

%Y-%m-%d-%filltext:name=title%.md

;tem

---
layout: post
title: 
author: Chuck Grimmett
date: %Y-%m-%d
category: TIL
feature-img: "/img/defaults/%snippet:;random-img%"
tags: 
- 
excerpt: <p></p>
---
### Today I learned:

Find this post useful?

Buy me a coffeeBuy me a coffee