Skip to content

Instantly share code, notes, and snippets.

@roman-yagodin
Created December 2, 2023 19:08
Show Gist options
  • Save roman-yagodin/df65fdba26582b62332e05db54b2a8b9 to your computer and use it in GitHub Desktop.
Save roman-yagodin/df65fdba26582b62332e05db54b2a8b9 to your computer and use it in GitHub Desktop.
Convert Tomboy/Gnote notes to Obsidian
Push-Location
Set-Location "$env:HOMEPATH/Projects/tomboy2obsidian/notes"
Get-ChildItem -Filter "*.note" | ForEach-Object {
[xml]$xml = Get-Content -Path $_.FullName
$tags = $xml.note.tags.InnerText
$tags = $tags -replace "system:notebook:", ""
$tags = $tags -replace "system:template", ""
$invalidFileNameChars = [System.IO.Path]::GetInvalidFileNameChars()
$mdFileName = $xml.note.title
for ($i = 0; $i -lt $invalidFileNameChars.Length; $i++) {
$mdFileName = $mdFileName.Replace($invalidFileNameChars[$i].ToString(), "")
}
$mdFileName = $mdFileName.Trim() + ".md"
while ([System.IO.File]::Exists($mdFileName)) {
$mdFileName = "_" + $mdFileName
}
$encoding = "utf8"
"" | Out-File $mdFileName -NoNewline -Encoding $encoding
if ($tags.Length -gt 0) {
"---" | Out-File $mdFileName -Append -Encoding $encoding
"tags:" | Out-File $mdFileName -Append -Encoding $encoding
(" - " + $tags) | Out-File $mdFileName -Append -Encoding $encoding
"---" | Out-File $mdFileName -Append -Encoding $encoding
}
$xml.note.text.'note-content'.InnerText | Out-File -Append $mdFileName -Encoding $encoding
}
Pop-Location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment