Skip to content

Instantly share code, notes, and snippets.

@t3rse
Last active Aug 29, 2015
Embed
What would you like to do?
$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