From f29af0237ffe934d3b85c74b243b808beda7afbd Mon Sep 17 00:00:00 2001 From: nixsee Date: Thu, 1 Oct 2020 20:04:29 -0600 Subject: [PATCH] Update ConvertOneNote2MarkDown-v2.ps1 --- ConvertOneNote2MarkDown-v2.ps1 | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/ConvertOneNote2MarkDown-v2.ps1 b/ConvertOneNote2MarkDown-v2.ps1 index e55a287..f659904 100644 --- a/ConvertOneNote2MarkDown-v2.ps1 +++ b/ConvertOneNote2MarkDown-v2.ps1 @@ -296,7 +296,8 @@ $notesdestpath = Read-Host -Prompt "Entry" "1: Discard intermediate .docx files - Default" "2: Keep .docx files" [int] $keepdocx = Read-Host -Prompt "Entry" - +"" +"-----------------------------------------------" # prompt for prefix vs subfolders "1: Create folders for subpages (e.g. Page\Subpage.md)- Default" "2: Add prefixes for subpages (e.g. Page_Subpage.md)" @@ -388,6 +389,42 @@ if (Test-Path -Path $notesdestpath) { New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)" -Name "$($sectiongroupFileName2)" -ItemType "directory" -ErrorAction SilentlyContinue $sectiongroupFilePath2 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)" ProcessSections $sectiongroup2 $sectiongroupFilePath2 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup3 in $sectiongroup2.SectionGroup) { + $levelsfromroot = 3 + if ($sectiongroup3.isRecycleBin -ne 'true') { + "### " + $sectiongroup3.Name + $sectiongroupFileName3 = "$($sectiongroup3.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)" -Name "$($sectiongroupFileName3)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath3 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)" + ProcessSections $sectiongroup3 $sectiongroupFilePath3 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup4 in $sectiongroup3.SectionGroup) { + $levelsfromroot = 4 + if ($sectiongroup4.isRecycleBin -ne 'true') { + "#### " + $sectiongroup4.Name + $sectiongroupFileName4 = "$($sectiongroup4.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)" -Name "$($sectiongroupFileName4)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath4 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)" + ProcessSections $sectiongroup4 $sectiongroupFilePath4 + + #start looping through any 2nd level section groups within the 1st level section group + foreach ($sectiongroup5 in $sectiongroup4.SectionGroup) { + $levelsfromroot = 5 + if ($sectiongroup5.isRecycleBin -ne 'true') { + "#### " + $sectiongroup5.Name + $sectiongroupFileName5 = "$($sectiongroup5.Name)" | Remove-InvalidFileNameChars + New-Item -Path "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)" -Name "$($sectiongroupFileName5)" -ItemType "directory" -ErrorAction SilentlyContinue + $sectiongroupFilePath5 = "$($notesdestpath)\$($notebookFileName)\$($sectiongroupFileName1)\$($sectiongroupFileName2)\$($sectiongroupFileName3)\$($sectiongroupFileName4)\\$($sectiongroupFileName5)" + ProcessSections $sectiongroup5 $sectiongroupFilePath5 + } + } + } + } + } + } } } }