Here's the script I use to generate tags for my Subtext posts. It writes the tag HTML to the screen and also copies it to the clipboard for immediate pasting:
if ($args.Length -ne 2)
{
write-host 'Two arguments (site and tag list) expected'
write-host 'Example: tags del.icio.us "scripts tags llama"'
return
}
$site = $args[0]
$input = $args[1]
$delim = ' '
$splits = $input.Split($delim.ToCharArray())
$header = '<p class="tags">tags: '
$footer = '</p>'
$format = '<a href="http://' + $site + '/tag/{0}"'
$format += ' target="_blank" rel="tag">{0}</a> '
$html = new-object System.Text.StringBuilder
[void]$html.Append($header)
for ($i = 0; $i -le $splits.Length; $i++)
{
if ($splits[$i].Length -ge 1)
{
$newText = [System.String]::Format($format, $splits[$i])
[void]$html.Append($newText)
}
}
[void]$html.Append($footer)
set-clipboard -text $html
write-host $html
Example:
tags del.icio.us 'snow cookie alpaca'
... generates the following HTML:
<p class="tags">tags:
<a href="http://del.icio.us/tag/snow"
target="_blank" rel="tag">snow</a>
<a href="http://del.icio.us/tag/cookie"
target="_blank" rel="tag">cookie</a>
<a href="http://del.icio.us/tag/alpaca"
target="_blank" rel="tag">alpaca</a>
</p>
Have fun.
tags: subtext tags powershell script