cmc/cleberg.net
My personal web garden & blog.
clone: git clone https://gitbay.org/cmc/cleberg.net.git
main: content/blog/2024-04-06-convert-onenote-to-markdown.org · raw
1#+date: [2024-04-06 Sat 00:00:00]
2#+title: OneNote to Org: Escape the Microsoft Format
3#+description: Converting OneNote files to Markdown or Org Mode with Pandoc.
4#+slug: convert-onenote-to-markdown
5#+filetags: :emacs:
6
7If you're looking to convert your OneNote content to another format, such as
8Markdown or Org-Mode, you're in luck. I use a solution that doesn't require
9other programs, such as Evernote or Notion. Personally, I used this solution on
10a managed corporate laptop that doesn't allow installation of other programs
11like these.
12
13This solution uses OneNote and Pandoc on Windows 10.
14
15* Export OneNote Content to Word
16
17To start, export any pages or tabs from OneNote to the Word format (=.docx=):
18
191. Open OneNote desktop.
202. Select =File= and then =Export=.
213. Select the scope of content to export, such as =Tab= or =Page=.
224. Name and save the file in an easy to remember location. I recommend your
23 Downloads or Desktop folder.
24
25See below for a visual walkthrough of the export process.
26
27* Download Pandoc
28
29Start by downloading Pandoc from their [[https://github.com/jgm/pandoc/releases][GitHub releases]] page. I cannot install
30=.msi= files on my corporate laptop, so I downloaded the
31=pandoc-3.1.12.3-windows-x86_64.zip= file, which contains a simple =.exe= file
32that you do not need to install - you will simply run it from the command line
33below.
34
35Once downloaded, unzip the archive and move the =pandoc.exe= file to the same
36folder where your Word documents were saved above. If you prefer, you can move
37this file to an easier location, such as =C:\Users\youruser\Downloads=.
38
39* Convert Word to Markdown
40
41In this example, I will be converting the Word documents to Markdown, but Pandoc
42supports [[https://github.com/jgm/pandoc?tab=readme-ov-file#the-universal-markup-converter][a ton of different formats for conversion]]. Choose the format you prefer
43and then modify the following commands as needed.
44
45To perform the conversion, open the Command Prompt. If you can't find it, open
46the start menu and search for it.
47
48Within the command prompt, navigate to the directory where you stored the
49=pandoc.exe= file and the Word documents.
50
51#+begin_src ps1
52cd "C:\Users\yourusername\Downloads"
53#+end_src
54
55You can verify that you're in the correct directory with the =dir=
56command.
57
58#+begin_src ps1
59dir
60#+end_src
61
62Once you have verified that you have the command prompt open in the correct
63directory with the =pandoc.exe= and the Word documents, you can run the
64following loop to convert all Word documents to Markdown.
65
66#+begin_src ps1
67for %f in (*.docx) do (pandoc.exe --extract-media=. --wrap=preserve "%f" -o "%f.md")
68#+end_src
69
70This loop will perform the following actions:
71
721. Find all documents matching the pattern =*.docx=, which means all Word
73 documents ending with that file extension.
742. Iterate through all files found in step 1.
753. For each file, perform the pandoc command.
764. Within the pandoc command, =--extract-media= saves all media found in the
77 files to the current folder, with pandoc automatically creating a =media=
78 subfolder to hold all images.
795. Within the pandoc command, =--wrap=preserve= will attempt to prseerve the
80 wrapping from the source document.
816. Within the pandoc command, the final step is to specify the output path with
82 =-o=. This option adds the =.md= file extension to recognize the output files
83 as Markdown files.
84
85If you want to export to another format, simply specify the =-f==/=--from== and
86=-t==/=--to== options.
87
88For example, you can convert the Word document to org-mode. You can also convert
89to one format and subsequently convert to other formats as needed.
90
91#+begin_src ps1
92pandoc.exe -f docx -t org file.docx
93#+end_src