New Tool for Migration from OneNote - updated and improved version

Apologies @aaron - I didn’t notice this comment before!

I doubt it would work for the appstore version (which is pretty terrible software anyway), but I have 365 and it works fine (if I’m not mistaken, it isn’t even part of 365 and is its own product that anyone can use for free - https://www.onenote.com/download)

great work! thank you very much

Wow this is great. Finally gave it a go, but it looks like it only handles 2 levels of nested section groups, and in some cases I have 3-4 :grimacing:

Yeah, I only made it do 2 levels of section groups (whereas the original did 0) because that’s all I needed.

If you know how to do basic coding (which is all I’m capable of), it shouldn’t be terribly difficult to add in however many levels you need by copying the foreach loop around line 380 (not sure exactly what line it is in the file version you have) and just keep pasting them within each other, then just increment the numbers 1,2,3… however many you want.

There’s probably a smart way to either automatically adjust the number of loops or at least allow for the user to enter how many levels they want. But I honestly don’t want to get sucked back into this code again haha. I’m happy to incorporate any improvements anyone else has!

@sam.baron

Yeah, it appears that function recursion could handle unlimited section group depth - probably just one for loop that has an if statement to check if the current item is a section group (in which case it would call the function on itself again) or a page (in which case it would call the process page function).

But I am not a good enough coder to do this rapidly, so I just know it would be an entire day of reading articles and futzing around. I don’t have time for that, especially when you can copy and paste the for loops, change the numbers and lengthen the filepath for each nested loop - maybe a 5-10 min job.

Let me know how it goes!

@nixsee Thank you so much for the detailed response and context. I could probably figure out the section group recursion also, but not sure I want to, haha. I haven’t done anything with Powershell scripts before.

I may revisit the OneNote -> Evernote -> Notion -> Markdown route. I have existing accounts for all of these apps, and I’ve already transferred Notion pages to my Obsidian vault.

@sam.baron I buckled and added nesting to 5 levels. Let me know if it doesn’t work. If you need more, it should be quite clear what needs to be done by looking at the changes in the various nested foreach loops near the end of the file.

Can I utilize this code to write notes in OneNote on pther devices and then periodically running the script to obtain the MD files to be added to obsidian?

I would just need a single page which serves as an index, and other pages that are listed in the index.

If I re-run the code multiple times, will it overwrite or convert only those which are not converted earlier?

Hello,
I am new to this and not as tech-savvy as most people using obsidian seem to be. Can you migrate from OneNote to obsidian on a mac? What are the specific steps needed to do so? I have not used GitHub before and have never worked with code. If I do convert OneNote to markdown/put it into obsidian what should be preserved and what will be missing?

1 Like

@nixsee Hi there. I’m migrating away from all Microsoft software. I run LM Debian now and have tons of notes in OneDrive online version. I noticed this tool is for Windows. Is there another for Linux?
Thank you.

Sorry, I haven’t been around here for a while and just saw this. I can’t think of any simple way to keep track of and only update new notes - this script will export everything in all of the open Notebooks, and would overwrite anything with the same titles in the same location.

You could exports all notes to a different folder and then select what you want to be imported into Obsidian, or you could put the new notes into its own Notebook and just export those notes by closing other notebooks.

Is this helpful?

This script only works on Windows. I suspect your best bet is to export from Onenote to Evernote, then Evernote to Joplin, then Joplin to Markdown. There are other posts on how to do this if you search the forum. Good luck!

Same as I said above to Mary - this only works on Windows. Perhaps the code could be amended for Linux, but i have no idea how. I’d suggest either getting Windows or doing Onenote->Evernote->Joplin->Markdown (if those are possible on linux…)

I just converted my notes and left onenote altogether. So no need for updating each time.
Thanks :slight_smile:

@nixsee
Thank you for your help. I took the time to actually purge all my note and migrated only the ones I need the most. Enjoying Obsidian now!

Not a bad strategy! I’m still dealing with the mess that I exported in bulk…

Hello, everyone! My first post here (How is everybody today? :grinning:), and I have a question: I have attempted to run the OneNote migration tool, and I have managed to make it to the step which asks for the prompts. Once I answer all the prompts, I get this error: InvalidOperation…unable to find type [Microsoft.Office.InterOp.OneNOte.HierarchyScope]. I am guessing this means something about my OneNote, but I do have it open, and it is OneNote365. Any suggestions?

Hi Mary,

This is the simplest non-techie way I have found so far. It’s not a ‘one-click’ solution but does not involve any code or scripts directly thanks to some work by somebody who goes by the moniker sspeiser.

This method also works for Linux and Windows users! The Instructions below are also attached in a zip file in markdown format.

You do have to install the Joplin app (free) to act as a middle man to convert an ENEX file to Markdown file.

Joplin installs as an app on a Mac so is easy to remove by deleting from the applications folder once you are done converting your files.

https://joplinapp.org/

scroll down the page and find the link to the download for mac

Now to rescue your OneNote Data from the clutches of Microsoft go to this site:-

https://sspeiser.github.io/onenote-export/

At the bottom of the web page click on the link

Once you complete login at the bottom of the page there is a link

Pasted image 20210207132518

or at the top of the page click on Notes

A new page loads and a blue pack man chomps on some dots while it searches your OneNote data… It really does take a while… about 3 minutes for my files

Pasted image 20210207132945

Once the data has been scanned you will see a list of OneNote books

Now is the time to be patient

Microsoft uses a process called throttling to limit how many requests for data a program can pull from their systems. For OneNote that is 120 items per minute and 400 per hour as a maximum then Microsoft begins refusing requests. Each page and attachment is a request. so you soon reach the 400 mark.

I found that if you ask for too much at once it will never work.

I downloaded section by section unless I knew the section was very small and then pulled a few at a time.

If the download appears to stop for more than 60 seconds then it probably will never complete. Cancel the download, leave the web page open, go do something else, and try again later when Microsoft have stopped throttling.


Note - There may be some sections that will not download

  • These stubborn ones may be too big - split them into several sections in OneNote.
  • Or you may have a page that just makes the program hang.
    • These are hard to find but if there are many large attachments these may be the cause.
    • Trial and error I’m afraid, remove pages until it works and the one removed before it starts working is the culprit.
    • Or if you know you have a busy note, remove any attachments (save to disk and then remove them from the OneNote note)
    • I had one page in a section that had nothing but one sentence, one small pdf and one small section of inking on it… removing each of these, one by one, and it still would not download. Then Deleting the now blank page…the section would download. Weird and just another reason to use Markdown files and Obsidian!
    • If you still cannot download that page/section a more techie solution is needed. I’m afraid… or an ‘analogue’ approach with Mr Copy and Mr Paste…

So select some sections

Then click on a download option for ENEX

Pasted image 20210207133608

The file will download as

Pasted image 20210207134602

In Joplin form the file menu choose Import -> As ENEX Evernote Export File (as Markdown)

Your notes will be in Joplin…

…but don’t leave them there! Keep going! Obsidian is the way forwards…

In Joplin you will see a set of notes named Welcome - right click and delete (else it will get exported with your OneNote data)

Pasted image 20210207140158

In Joplin from the file menu choose Export All -> MD - Markdown

Choose an empty, or create a new, folder and click OK
In the folder you will have a folder of resources and a folder with your Markdown files

Now you can create a new vault with these files of copy them into an existing vault but please note the following important point…

The attachments and Markdown files should be moved together in the folders they are in.

You can rename the folder the Markdown files are in but do not rename the _resources folder else links to images will be lost.

So you may end up with something like this once all in a vault…

  1. Folders for each section and all resources in one folder
    Pasted image 20210207141956

  2. One Folder for all notes and one for all resources
    ![Pasted image 20210207142631|690x279, 50%](upload://9R7AJMRkFwAri6zt6xRuR2xt8JOneNoteToObsidian.zip (1.9 MB) I.png)

The Markdown files and attachments/images must stay in separate folders. The following will lose the links to the attachments/images

not_work


Skip this block if you want as I’m going to get a little geek on you… Links look like this
![$value.png](../_resources/16bb45bed14d373af341ac69dbc20a2d.png)
The ../_resources reads as - go back one folder and up into the _resources folder - and is why they have to be kept in the above pattern of folders to maintain the links.


For this example, I just created a vault using the existing folder “My Obsidian Vault”, shown in the above folder examples above.

Voila OneNote in Obsidian

Once finished, delete any data in the Joplin app

Pasted image 20210207143902

and then delete the app

Good luck!

3 Likes

Nice guide! I originally used Evernote to export from onenote, then imported into Joplin and converted to markdown - it does it all offline so you don’t have the waiting game you’ve described.

But ultimately I prefer this PowerShell script for many reasons.

I’m not sure. By onenote 365, do you mean onenote 2016 that is free for download? My suspicion is you’re using the windows store version, despite having office 365.