Evernote to Obsidian, work in progress

As per my previous post, I went ahead and migrated myself from Evernote to Obsidian yesterday. I’m now almost at the point of no return. (Or at least at the point where I’d have wasted a lot of effort if I were to throw it away now and go back to Evernote.)

I used Yarle for the migration. I’d done several experimental, partial, migrations first. For the final migration, I did all of my Evernote notebooks all at once. (I had a thought in my head that Yarle might resolve cross-notebook links if I did that.) The migration went pretty smoothly, but Yarle seemed to lock up at one point. I checked the count on the output files, and it seemed like it had created all of them, so I did an “end task” on it and proceeded from there.

In the end, I’ve wound up with a lot of broken links. I’m starting to wonder if killing the Yarle process was a mistake. Maybe it had created all of the .md files, but was still reconciling the links? I don’t really know enough about how Yarle works.

Either way, I’m now cleaning up hundreds of broken links. With the broken links plugin, I’m able to at least identify them easily. There are actually two different kinds of broken links in my vault now: there are many ‘regular’ broken Markdown links; I can ID those with the plugin. Then, there are links that point out to share.evernote.com, which didn’t fully get converted to Markdown links. Those are technically ‘valid’ links, but of course they open up my original Evernote notes in a web browser, so I’ll need to clean those up too.

I started doing the link cleanup manually, but at some point, I saw how big the job was getting, and decided to write a couple of helper scripts. With the help of Kagi Assistant, I wrote two PowerShell scripts. The first cleaned up links where Yarle had left them in a format like this:
[[guid/guid|name of link]]
In that case, I wanted to change them to:
[[name of link]]

Here’s the script I used:

 Get-ChildItem -Recurse -Filter *.md | ForEach-Object {
    $content = $_ | Get-Content -Raw
    $new = [regex]::Replace($content,
        '[[[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|([^]]+)]]',
        {param($m) "[[{0}]]" -f $m.Groups[1].Value},
        'IgnoreCase'
    )
    if ($new -ne $content) {
        $_.FullName                    # show changed file
        Set-Content -NoNewline -Path $_.FullName -Value $new
    }
 }

And for the second case, I wanted to clean up the external Evernote links, like this:
[name of link](https://share.evernote.com/note/guid)
To again change them to this:
[[name of link]]

So here’s that script:

Get-ChildItem -Recurse -Filter *.md | ForEach-Object {
    $content = $_ | Get-Content -Raw
    $new = [regex]::Replace($content,
        '[([^]]+)](https?://share.evernote.com/[^)]+)',
        {param($m) "[[{0}]]" -f $m.Groups[1].Value},
        'IgnoreCase'
    )
    if ($new -ne $content) {
        $_.FullName                    # print the altered file
        Set-Content -NoNewline -Path $_.FullName -Value $new
    }
}

I didn’t even really test these scripts, I just backed up my vault, then ran them. And, surprisingly, they seemed to work right on the first attempt.

So that got me through most of the link cleanup. I then did a bunch of manual fixes, and just kept going until the “broken links” list was empty.

(I may have mixed up my tenses in this post. I started writing it as I was working on the migration, and finished it after I got all the link cleanup done. Sorry.)

My next task will likely be attachment cleanup. I guess that’ll go in yet another blog post!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.