SjoerdV / ConvertOneNote2MarkDown

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!
GNU General Public License v3.0
196 stars 113 forks source link

subpages with identical names but in different parents overwrite each other #23

Closed FrankEppink closed 2 years ago

FrankEppink commented 2 years ago

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

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.

SjoerdV commented 2 years ago

@FrankEppink you were absolutely right. Corrected the script to your recommendations. Thanks a lot for making this somewhat better. If you agree with the commit please close the issue.

FrankEppink commented 2 years ago

thanks for the quick fix