Automating Blog Posts with AppleScript v2

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: 

--- ### Today I learned:


Comments

Leave a Reply

Webmentions

If you've written a response on your own site, you can enter that post's URL to reply with a Webmention.

The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.

Learn more about Webmentions.