Created
December 2, 2023 19:08
-
-
Save roman-yagodin/df65fdba26582b62332e05db54b2a8b9 to your computer and use it in GitHub Desktop.
Convert Tomboy/Gnote notes to Obsidian
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
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