Last active
August 22, 2018 10:56
-
-
Save RichieBzzzt/7d86552a1660059cd7ab7128f47cd281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[xml]$xml = Get-Content "C:\phbx\phbx\phbx\1.xml" | |
$folderformarkdown = "C:\phbx\phbx\phbx\markdown4" | |
$xmlposts = $xml.rss.channel.Item | Where-Object {($_.creator -eq "phoenixultd") -and ($_.status -eq "publish")} | |
foreach ($xp in $xmlPosts) | |
{ | |
$content = $xp.content.InnerText | |
$date = Get-Date $xp.pubDate -Format 'yyyy-MM-dd' | |
$tags = @() | |
for ($i = 0; $i -le $xp.category.Count-1; $i++) | |
{ | |
$tag = $xp.category[$i].nicename -replace "\W" | |
$tags += $tag | |
} | |
$tagMeta = "tags = [" | |
foreach ($t in $tags){ | |
$tagMeta = "$tagMeta ""$t""" | |
if ($t -ne $tags[-1]){ | |
$tagMeta = $tagMeta + "," | |
} | |
} | |
$tagMeta = "$($tagMeta)]" | |
#create metadata | |
$meta=" | |
+++ | |
title = ""$($xp.title)"" | |
date = ""$date"" | |
draft = false | |
$tagMeta | |
+++ | |
`n" | |
$title = $xp.title -replace "\W", "-" | |
$fileName = "$($date)-$($title).md" | |
$path = Join-Path $folderformarkdown $fileName | |
$value = "$meta $content" | Out-File $path -encoding utf8 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment