Skip to content

Instantly share code, notes, and snippets.

@t3rse
Last active August 29, 2015 14:00
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 t3rse/11241697 to your computer and use it in GitHub Desktop.
Save t3rse/11241697 to your computer and use it in GitHub Desktop.
$file_name = "{0}-{1}.html"
$post_template =
@"
---
layout: post
title: `"{0}`"
comments: true
---
{1}
"@
$xml = [xml](get-content BlogML.xml)
$xml.blog.posts.post | % {
$name = $file_name -f [DateTime]::Parse($_.Attributes["date-created"].Value).ToString("yyyy-MM-dd"), ($_.Attributes["post-url"].Value -replace ".aspx", "")
$name = $name -replace "/post/\d{4}/\d{2}/\d{2}/", ""
$value = $post_template -f $_.title.InnerText, $_.content.InnerText
New-Item -Path . -Name $name -Value $value -ItemType file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment