Last active
January 5, 2021 11:26
-
-
Save JackGruber/27b46417df4600f858c609bac9e99493 to your computer and use it in GitHub Desktop.
Joplin powershell note export
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
$endpoint = "http://localhost:41184" | |
$token = "xxxxxxxxxx" | |
Try | |
{ | |
$uri = ($endpoint + "/ping") | |
if( (Invoke-WebRequest -Uri $uri).Content -ne "JoplinClipperServer") | |
{ | |
Write-Host "No Joplin API endpoint" -ForegroundColor Red | |
exit | |
} | |
} | |
Catch | |
{ | |
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red | |
exit | |
} | |
Try | |
{ | |
$page = 1 | |
Do | |
{ | |
$uri = ($endpoint + "/notes?token=" + $token + "&fields=id,title,body&page=" + $page) | |
$notes = (Invoke-WebRequest -Uri $uri).Content | |
$notes = $notes | ConvertFrom-Json | |
for ($i=0; $i -lt $notes.items.Count; $i++) { | |
$id = $notes.items[$i].id | |
$body = $notes.items[$i].body | |
$title = $notes.items[$i].title | |
$body | Out-File -FilePath ($title + ".md") | |
} | |
$page = $page +1 | |
} While ( $notes.has_more -eq $True ) | |
} | |
Catch | |
{ | |
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red | |
exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment