how to change default directory in jupyter notebook code example

Example 1: set the root directory when starting jupyter notebooks

# To change the Jupyter Notebooks startup directory:
1. From the command line (shell) run: jupyter notebook --generate-config
2. View the config file at: ~/.jupyter/jupyter_notebook_config.py
3. Change the line: c.NotebookApp.notebook_dir = '' to
	c.NotebookApp.notebook_dir = '/path/to/desired/startup/directory'

Example 2: (change OR open) ("jupyter notebook" OR ipython) (folder OR directory OR "working directory" OR path) "--notebook-dir="

jupyter notebook --notebook-dir=/Users/yourname/folder1/folder2/

Example 3: how to set default file directory for jupyter notebook

import os
os.getcwd()
Out[2]:
'/tmp'
In [3]:

os.chdir('/')
In [4]:


os.getcwd()
Out[4]:
'/'
In [ ]:

Example 4: how to set default file directory for jupyter notebook

%cd "C:\abc\xyz\"