Giter Site home page Giter Site logo

sjoerdv / convertonenote2markdown Goto Github PK

View Code? Open in Web Editor NEW
195.0 195.0 113.0 36 KB

Ready to make the step to Markdown and saying farewell to your OneNote, EverNote or whatever proprietary note taking tool you are using? Nothing beats clear text, right? Read on!

License: GNU General Public License v3.0

PowerShell 100.00%

convertonenote2markdown's People

Contributors

sjoerdv avatar wolfteeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

convertonenote2markdown's Issues

Exception calling "GetHierarchy" with "3" argument(s)

Exception calling "GetHierarchy" with "3" argument(s): "Unable to cast COM object of type
'Microsoft.Office.Interop.OneNote.Application2Class' to interface type
'Microsoft.Office.Interop.OneNote.IApplicationCOM'. This operation failed because the QueryInterface call on the COM
component for the interface with IID '{452AC71A-B655-4967-A208-A4CC39DD7949}' failed due to the following error:
Interface not registered (Exception from HRESULT: 0x80040155)."
At C:\OneNote2MarkDown\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:21 char:3
+   $OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.Hierarc ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidCastException

Windows 10 on a Surface Pro 6
Office Professional Plus 2019

What's going wrong here? (apart from the Markdown markup)

PS C:\Users\Toontje\ConvertOneNote2MarkDown> .\ConvertOneNote2MarkDown.ps1
Enter the (preferably empty!) folder path (without trailing backslash!) that will contain your resulting Notes structure. ex. 'c:\temp\notes': ~/export

Ton @ Sites - Company Inc


    Directory: C:\Users\Toontje\export


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         7/7/2020   5:09 PM                Ton_@_Sites_-_Company_Inc
==============
## Customers
## Tech
--------------
### Quick Notes


    Directory: C:\Users\Toontje\export\Ton_@_Sites_-_Company_Inc


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         7/7/2020   5:09 PM                Quick_Notes
#### Lab
Error while publishing file 'Lab' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: ~/export\Ton_@_Sites_-_Company_Inc\Quick_Notes\Lab.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'C:\Users\Toontje\export\Ton_@_Sites_-_Company_Inc\Quick_Notes\Lab.md' because it
does not exist.
At C:\Users\Toontje\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Ton Ma...ck_Notes\Lab.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Lab': You cannot call a method on a null-valued expression.
#### Company Wifi
Error while publishing file 'Company Wifi' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: ~/export\Ton_@_Sites_-_Company_Inc\Quick_Notes\Company_Wifi.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'C:\Users\Toontje\export\Ton_@_Sites_-_Company_Inc\Quick_Notes\Company_Wifi.md'
because it does not exist.
At C:\Users\Toontje\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Ton Ma...\Company_Wifi.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Company Wifi': You cannot call a method on a null-valued expression.
#### JOIN WEBEX MEETING
Error while publishing file 'JOIN WEBEX MEETING' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: ~/export\Ton_@_Sites_-_Company_Inc\Quick_Notes\JOIN_WEBEX_MEETING.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'C:\Users\Ton
Machielsen\export\Ton_@_Sites_-_Company_Inc\Quick_Notes\JOIN_WEBEX_MEETING.md' because it does not exist.
At C:\Users\Toontje\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Ton Ma...EBEX_MEETING.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'JOIN WEBEX MEETING': You cannot call a method on a null-valued expression.
--------------
### Personal
d-----         7/7/2020   5:09 PM                Personal
#### Home network
Error while publishing file 'Home network' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: ~/export\Ton_@_Sites_-_Company_Inc\Personal\Home_network.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'C:\Users\Toontje\export\Ton_@_Sites_-_Company_Inc\Personal\Home_network.md'
because it does not exist.
At C:\Users\Toontje\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Ton Ma...Home_network.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Home network': You cannot call a method on a null-valued expression.

subpages with identical names but in different parents overwrite each other

Problem

OneNote subpages are not correctly handled in the scenario with two subpages with the same name but belonging to different parents. The created word documents have the same name, hence the latter one overwrites the earlier one.

Example

  • Parentpage01
    • SubpageA
  • Parentpage02
    • SubpageA

This will result in a single SubpageA.docx word document, where the latter one has overwritten the earlier one.

Fix

I think the bug would be fixed by adding the second statement

$fullexportpathwithoutextension = "$($fullexportdirpath)\$($pagename)"
$fullexportpath = "$($fullexportpathwithoutextension).docx"

after https://github.com/SjoerdV/ConvertOneNote2MarkDown/blob/master/ConvertOneNote2MarkDown.ps1#L118

so that the line

$OneNote.Publish($pageid, $fullexportpath, "pfWord", "")

in https://github.com/SjoerdV/ConvertOneNote2MarkDown/blob/master/ConvertOneNote2MarkDown.ps1#L122

actually uses the correct and unique name including the pagename.

also the earlier check in
https://github.com/SjoerdV/ConvertOneNote2MarkDown/blob/master/ConvertOneNote2MarkDown.ps1#L65
should be moved lower into line 120 to check the actual word file path.

I modified the code to allow for section groups

I don't know how to share/push this - probably don't have access. But I modified this to allow for top-level section groups, but it kills any top-level section functionality, so you'd have to move all section to a section group to use it. Quite useful for me because I really do need that extra level of hierarchy without creating a new notebook.

I made a function "ProcessSections" that gets called from within the SectionGroup For loop, with the idea that it could then be called from within another loop to process any top-level sections, but got to the edge of my capabilities...

Anyway, feel free to incorporate this however you like.
ConvertOneNote2MarkDownSectionGroups.zip

@johnkyle4, you might be interested in this as well?

Error: Server execution failed

Hi, I was trying to run script over my nootebooks but every time I'm getting the following error:

due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005
(CO_E_SERVER_EXEC_FAILURE)).
At C:\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:18 char:14
+   $OneNote = New-Object -ComObject OneNote.Application
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

You cannot call a method on a null-valued expression.
At C:\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:21 char:3
+   $OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.Hierarc ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
At C:\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:216 char:3
+   [System.Runtime.Interopservices.Marshal]::ReleaseComObject($OneNote ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException

Remove-Variable : Cannot find a variable with the name 'OneNote'.
At C:\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:217 char:3
+   Remove-Variable OneNote
+   ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (OneNote:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand```

I installed pandoc and I am using an absolute path. Onenote is opened when executing the script. OS: Win 10 18363

implicit type conversion not possible (Application2Class => IApplicationCOM)

When I run I get this error

Enter the (preferably empty!) folder path (without trailing backslash!) that will contain your resulting Notes structure. ex. 'c:\temp\notes': d:\onenote_2_markdown
Ausnahme beim Aufrufen von "GetHierarchy" mit 3 Argument(en):  "Das COM-Objekt des Typs
"Microsoft.Office.Interop.OneNote.Application2Class" kann nicht in den Schnittstellentyp
"Microsoft.Office.Interop.OneNote.IApplicationCOM" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt
werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID
"{452AC71A-B655-4967-A208-A4CC39DD7949}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Bibliothek
nicht registriert. (Ausnahme von HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))."
In D:\Repos\GitHub\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:21 Zeichen:3
+   $OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.Hierarc ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidCastException

Windows 10, OneNote is part of the current Office 365
Or should I try the Windows 10 Version?
Or should I search for the 2016 Version?

Replace absolute path of images by relative path

So, I've successfully converted all my Onenote notebooks to markdown, thanks for that! You saved me a tremendous amount of work.

I've moved all notes from the directory I initially put the markdown files to another directory, and noticed that images stopped working because the path referenced is absolute, e.g. 'D:/User/MyNotes/media/...'. I replaced this with the relative path of './media/...' to have them all work again.

I think this can be fixed somewhere around line 181 of the .ps1 file. I attempted a pull request, but I don't know enough of Powershell to replace the part of variable 'fullexportpathwithoutextension' so it just contains './media/.

This would have the script convert Onenote to markdown and lets you then move the notes around as you please!

Error when running the script

I've followed the instructions but when running the script I[ve got an error (below).
Windows 10 Version = 20H2 Build 19042.1288
OneNote version = 1808 (Msft office Professional Plus 2019)
Pandoc Version = 2.16.2

Error:

-New-Object : Retrieving the COM class factory for component with CLSID {DC67E480-C3CB-49F8-8232-60B0C2056C8E} failed
due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005
(CO_E_SERVER_EXEC_FAILURE)).
At C:\Users\edugoliv\Downloads\ConvertOneNote2MarkDown.ps1:18 char:14

  • $OneNote = New-Object -ComObject OneNote.Application
  •          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
    • FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

You cannot call a method on a null-valued expression.
At C:\Users\edugoliv\Downloads\ConvertOneNote2MarkDown.ps1:21 char:3

  • $OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.Hierarc ...
  • + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
    
    

Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
At C:\Users\edugoliv\Downloads\ConvertOneNote2MarkDown.ps1:219 char:3

  • [System.Runtime.Interopservices.Marshal]::ReleaseComObject($OneNote ...
  • + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException
    
    

Remove-Variable : Cannot find a variable with the name 'OneNote'.
At C:\Users\edugoliv\Downloads\ConvertOneNote2MarkDown.ps1:220 char:3

  • Remove-Variable OneNote
  • + CategoryInfo          : ObjectNotFound: (OneNote:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
    

[minor bug] duplicate names

when there is duplicate names, one will override the other.

image

I dont think it needs to be fixed (just an edgecase). Just want to report it.

Subfolders rather than appending a prefix for subpages?

I very much appreciate your treatment of subpages in relation to their parents - I'm pretty sure my other two solutions of Evernote->Joplin/Notion don't do this and you end up with a mass of unsorted pages.

But, while the prefixes keep them all in order in the file explorer, I will inevitably be renaming them to their original name after organizing/linking them. So, I'm wondering if subfolders could be created, which I can then drag files out of once they have been appropriately treated?

I can see where you handle this in the code, but it's far beyond me to change it.

Thanks!

Converter is adding ">" before all bullets, as well as extra lines

Thanks again for making this. Its a major improvement over my previous workflow of Onenote->Evernote-> Notion or Joplin. Though I've found what I consider to be a couple bugs and I hope you can help!

Here's a few screenshots.
Original:
image

After search and replace for "> ", to get rid of the quote blocks:
image

After removing extra lines:

image

The search and replace isn't a huge deal, though it becomes a trickier regex job when there are links and other formatting in the Onenote that use < >.

The extra lines are much more of a nuisance as it messes up the formatting of the bullet lists.

Anything that can be done about this?

Section Groups

The script is running fine until it hits a section group, then it exits with "0."

In my OneNote Notebook "root" I have a few sections like "Inbox", "To Read"... then all section groups (like "/bus," "/dev..." these contain many sections and more "sub"-section groups .) My collapsed "root" looks like this:

Inbox
To Read
/ bus
/ dev
/ home
/ life
/ music
/ work

I see in the docs:

Section Groups are listed but do not contain actual data, so these are ignored

Does this mean it can't navigate into a section group and is skipping all the section groups and exiting with no errors? So all sections to be exported need to be moved out of section groups and to the top level/root?

Error running script. Com class retreival.

New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed
due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:47 char:14

  • $OneNote = New-Object -ComObject OneNote.Application
  •          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
    • FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

Unable to find type [Microsoft.Office.InterOp.OneNote.HierarchyScope].
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:50 char:29

  • ... erarchy("", [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPage ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Offic....HierarchyScope:TypeName) [], RuntimeException
    • FullyQualifiedErrorId : TypeNotFound

Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:248 char:3

  • [System.Runtime.Interopservices.Marshal]::ReleaseComObject($OneNote ...
  • + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException
    
    

Remove-Variable : Cannot find a variable with the name 'OneNote'.
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:249 char:3

  • Remove-Variable OneNote
  • + CategoryInfo          : ObjectNotFound: (OneNote:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
    

Instructions for Installing from Chocolatey

Hi there, thanks for making this. I installed Chocolately using the instructions in the page you linked to. But I don't know how to install this script using it - I can't find it in their listed packages. Could you write some quick instructions for how to do so? Thanks!

Class not registered

Not sure what the problem is:

Class not registered
"
at Publish-OneNotePage, C:\users\coffeegrindsWindows\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown-v2.ps1: line 628
at Convert-OneNotePage<Process>, C:\users\coffeegrindsWindows\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown-v2.ps1: line 1135
at New-SectionGroupConversionConfig, C:\users\coffeegrindsWindows\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown-v2.ps1: line 1025
at Convert-OneNote2MarkDown, C:\users\coffeegrindsWindows\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown-v2.ps1: line 1435
at <ScriptBlock>, C:\users\coffeegrindsWindows\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown-v2.ps1: line 1471
at <ScriptBlock>, <No file>: line 1
Failed to publish page to docx file C:\users\coffeegrindsWindows\Downloads\converted-onenote\PERSONAL\docx\New-House-Neighbors.docx
Failed to convert page: New-House\Neighbors
Exception calling "Publish" with "4" argument(s): "Class not registered

Class not registered

More conversion errors

I'm running the script as Admin in Powershell ISE also Onenote as Admin (version 16.0.14430.20270).

First few notes seem to convert OK but with warnings:

pandoc.exe : [WARNING] Deprecated: --atx-headers. Use --markdown-headings=atx instead.
At C:\Users\G\Downloads\1convert\master\ConvertOneNote2MarkDown.ps1:132 char:17
+ ...             pandoc.exe -f docx -t gfm -i $fullexportpath -o "$($fulle ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ([WARNING] Depre...gs=atx instead.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Then the trouble really starts, all the following notes go something like this:

Error while publishing file 'Note Title' to docx: Exception calling "Publish" with "4" argument(s): "The remote p
rocedure call failed. (Exception from HRESULT: 0x800706BE)"
pandoc.exe : [WARNING] Deprecated: --atx-headers. Use --markdown-headings=atx instead.
At C:\Users\G\Downloads\1convert\master\ConvertOneNote2MarkDown.ps1:132 char:17
+ ...             pandoc.exe -f docx -t gfm -i $fullexportpath -o "$($fulle ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ([WARNING] Depre...gs=atx instead.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
couldn't unpack docx container: not enough bytes
Exception calling "GetPageContent" with "3" argument(s): "The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"
At C:\Users\G\Downloads\1convert\master\ConvertOneNote2MarkDown.ps1:141 char:15
+               $OneNote.GetPageContent($pageid, [ref]$pagexml, 7)
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException
 
Get-Content : Cannot find path 'C:\Users\G\Downloads\1convert\structure\FH\FH\Note Title.md' because it does 
not exist.
At C:\Users\G\Downloads\1convert\master\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -LiteralPath "$($fullexportpathwithoutextensi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\G\Down...Note Title.md:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
 
Error while renaming image file path references for file 'Note Title': You cannot call a method on a null-valued 
expression.

Suggestions please ...

Unexpected token ':"en"' in expression or statement.

Getting this error when running the script.

Line |
  40 |  … script type="application/json" id="client-env">{"locale":"en","featur …
     |                                                            ~~~~~
     | Unexpected token ':"en"' in expression or statement.

Am I doing something wrong?

Error when title is longer than 183 characters

First of all, thank you for this miraculous script. I am so close to realizing my dream of moving out of OneNote to Markdown.

I'm almost there. My prior errors were caused by not running OneNote in administrator mode, and not having MS Word installed. Now it's working, except...

Many of my OneNote pages have no title, just content. OneNote substitutes note content for blank titles.

I'm getting errors in this script when my titles are blank and the substituted content is over 183 characters.

Error while publishing file 'Nice. Watts a force of nature. Yeah I play professionally and tour frequently with a singer songwriter out of western canada. Portland is a real gas. Used to love playing at Satyricon back in the day' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: C:\Users\John\Desktop\OneNote\File_Cabinet\-_-_TEST\Nice._Watts_a_force_of_nature._Yeah_I_play_professionally_and_tour_frequently_with_a_singer_songwriter_out_of_western_canada._Portland_is_a_real_gas._Used_to_love_playing_at_Satyricon_back_in_the_day.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'C:\Users\John\Desktop\OneNote\File_Cabinet\-_-_TEST\Nice._Watts_a_force_of_nature._Yeah
_I_play_professionally_and_tour_frequently_with_a_singer_songwriter_out_of_western_canada._Portland_is_a_real_gas._Used
_to_love_playing_at_Satyricon_back_in_the_day.md' because it does not exist.
At C:\Users\John\Desktop\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\John\D...k_in_the_day.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Nice. Watts a force of nature. Yeah I play professionally and tour frequently with a singer songwriter out of western canada. Portland is a real gas. Used to love playing at Satyricon back in the day': You cannot call a method on a null-valued expression.

I am wondering if there is a way to modify your script to handle this, to do something like truncating the title? I have thousands of notes and I can't do it manually.

I've looked at some Onetastic macros but I can't find one that works to add a title to all pages.

Thank you for your help and for creating this script 🙏

Error while publishing file 'xxx' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x8004201A"

(probably the same as #15 )

It crashes on a specific file that has (in onenote) 2 entries with the same name in the same section

Error while publishing file 'something_specific' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x8004201A"

There are 2 md files, one with a _1, but the contents is identical which is not correct but this is because probably it continues after the catch. There is 1 word doc. I think the first one succeeds and then the second one somehow fails.

So the 2nd word document is raising the exception. I will place some more debug lines since in theory the word doc should be deleted at the end of the "for each page", so a new one, with a different page id can be written.

Error while publishing file '[xxx]' to docx: Exception calling "Publish" with "4" argument(s): "Class not registered

I'm getting errors like this:

[EDIT: I'm using OneNote 2016. I also have OneNote for Windows 10 installed. I followed all your directions, including Chocolately > Pandoc, and I'm running OneNote 2016 and PowerShell in administrator mode.]

Error while publishing file 'my doc.docx: Exception calling "Publish" with "4" argument(s): "Class not registered

Class not registered
"
couldn't unpack docx container: not enough bytes
Get-Content : Cannot find path 'C:\Users\John\Desktop\OneNote\File_Cabinet\-_Inbox\my_doc.md' because it does not exist.
At C:\Users\John\Desktop\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\John\D...my_doc.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'my doc': You cannot call a method on a null-valued expression.

`ConvertOneNote2MarkDown.ps1` exits after taking path, doesn't convert anything

I ran the script, entered in an absolute path that exists, and I briefly saw one of my notebook's names on the terminal window before it closed. I checked the folder to find that only one empty folder was created. What exactly happened?

On a related note, I think it would be very useful to include error messages in the script to better help the user understand why it might have failed, rather than simply exiting immediately.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.