Skip to content

Fix: Fix empty docx folder being left behind in the notebook folder when discarding .docx files - #205

Open
El1as42 wants to merge 1 commit into
theohbrothers:masterfrom
El1as42:fix/fix-bug-where-an-empty-docx-folder-was-left-in-the-notebook-folder-when-discarding-docx-files
Open

El1as42 wants to merge 1 commit into
theohbrothers:masterfrom
El1as42:fix/fix-bug-where-an-empty-docx-folder-was-left-in-the-notebook-folder-when-discarding-docx-files

Conversation

@El1as42

@El1as42 El1as42 commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #204

With $keepdocx = 1 (default), each page's .docx file is removed after conversion, but the notebook's docx folder is not. So an empty docx folder is left in every converted notebook's folder.

Changes

  • Convert-OneNotePage: after removing the page's .docx file, remove the docx folder if it is empty. It is created again for the next page, so it is gone after the last page. A folder that still contains files (e.g. from a previous run with $keepdocx = 2) is kept. With $keepdocx = 2, nothing changes.

Tests: Convert-OneNotePage tests that the folder is removed if it is empty, kept if it is not empty or with $keepdocx = 2, and that failing to remove it does not halt the conversion. Unit tests pass on Windows PowerShell 5.1 and PowerShell 7.0. In this repo's CI (run on my fork), all jobs that can currently run pass: Windows PowerShell 5.1 (windows-2022) and PowerShell 7.1 to 7.4. The other jobs currently fail for any PR, before checkout: the windows-2019 runner image was retired, and the PowerShell 6.0 to 7.0 container images are too old for actions/checkout (GLIBC_2.28' not found). Also tested on real notebook pages: no docx folder is left with $keepdocx = 1, and the folder and .docx files are kept with $keepdocx = 2.

Note: #195 keeps the docx folder when removing a notebook's previous output, so that .docx files can be reused. This is compatible, since the folder is only removed when it is empty.

🤖 Generated with Claude Code

… when discarding `.docx` files

With `$keepdocx = 1` (default), each page's `.docx` file is removed after conversion, but the notebook's `docx` folder was not, leaving an empty `docx` folder in every converted notebook.

Now the `docx` folder is removed after a page's `.docx` file is removed, if the folder is empty. It is created again for the next page. A folder that still contains files (e.g. from a previous run with `$keepdocx = 2`) is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty docx folder is left in each converted notebook's folder when discarding .docx files

1 participant