Lesson17_Delete_Convert: Deleting Files and Converting Jupyter Notebooks (.ipynb) to HTML¶
How to find your Jupyter nbconvert version¶
In [ ]:
jupyter nbconvert --version
If you want to see what will be deleted first ... Run this safer command before deleting anything:
for /d /r %i in (.ipynb_checkpoints) do @echo %i
It will list every .ipynb_checkpoints directory that would be removed
The following command recursively finds and deletes all .ipynb_checkpoints directories starting from the current directory
for /d /r %i in (.ipynb_checkpoints) do @if exist "%i" rd /s /q "%i"
What it does
- for /d /r — Recursively traverses all subdirectories.
- %i — Stores the path of each matching directory.
- (.ipynb_checkpoints) — Looks for directories named .ipynb_checkpoints.
- if exist "%i" — Verifies that the directory exists.
- rd /s /q "%i" — Removes the directory and all of its contents without prompting.
- /s = Delete all files and subdirectories.
- /q = Quiet mode (no confirmation prompts).
How to delete all .ipynb_checkpoints folders under a certain folder¶
To start from a specific folder
For example, to delete all .ipynb_checkpoints folders under C:\Explore regardless of your current directory:
cd /d C:\Explore
for /d /r %i in (.ipynb_checkpoints) do @if exist "%i" rd /s /q "%i"
How to delete all .html files from the current directory¶
del /s /q *.html
will permanently delete every .html file in the current directory and all of its subdirectories.
What the options mean
del — Delete files.
/s — Include all subdirectories.
/q — Quiet mode (do not ask for confirmation).
How to recursively convert every Jupyter notebook (.ipynb) under the current directory to HTML¶
for /r %i in (*.ipynb) do jupyter nbconvert --to html "%i"
What it does
for /r — Recursively searches all subdirectories.
%i — Stores the full path of each .ipynb file.
jupyter nbconvert --to html — Converts the notebook to HTML.
How to add a progress message so you can see which notebook is being processed¶
for /r %i in (*.ipynb) do @echo Converting "%i" & jupyter nbconvert --to html "%i"
How to convert a particular .ipynb file to a HTML file¶
In [ ]:
jupyter nbconvert --to html "C:\Explore\SAS\Combined_Lessons.ipynb"
How to convert multiple .ipynb files to HTML files on the same command line.¶
jupyter nbconvert --to html ^
"C:\Explore\SAS\Lesson1\Lesson1_Part1.ipynb" ^
"C:\Explore\SAS\Lesson14\Testing_Local_SAS_SASPy.ipynb"
How to convert multiple .ipynb files to HTML files on a single line.¶
jupyter nbconvert --to html "C:\Explore\SAS\Lesson1\Lesson1_Part1.ipynb" "C:\Explore\SAS\Lesson14\Testing_Local_SAS_SASPy.ipynb"