Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting all files in folder to .py files

Tags:

python

I was wondering if their is anyway to go through and make copies of each .ipynb file in a folder and then change that file to .py. I want to keep the .ipynb files but I would like to have a .py file as well. I know how to do it manually but would like a way to do it automatically for each file in a specified directory.

like image 761
Cannon Avatar asked Sep 02 '25 18:09

Cannon


2 Answers

Just try this at Cmd prompt inside that folder.

jupyter nbconvert *.ipynb --to script

Converts all .ipynb files to .py and retains all .ipynb files as well.
Hope it helps

For more details, Check this link as well Save .ipynb to .py automatically on saving notebook

like image 191
Karan Kaw Avatar answered Sep 04 '25 08:09

Karan Kaw


find . -name "*.py" -exec ipython nbconvert --to=python {} \; should work on Linux.

like image 25
0x5453 Avatar answered Sep 04 '25 06:09

0x5453