Navigating and Managing Files in Notebooks: Top Magic Commands

To efficiently manage folders, navigate directories, write to files, and execute scripts directly from your notebook, consider using these four highly effective magic commands that simplify these tasks:

✨ %mkdir: Create new folders.
✨ %cd: Navigate through directories.
✨ %%writefile: Write content to files.
✨ %run: Run external Python scripts.

%mkdir my_project
. --> current directory
└── my_project
%cd my_project
. 
└── my_project --> current directory
%%writefile process_data.py
print("Processing data...")
Writing process_data.py
%run process_data.py
Processing data...

 Run in Google Colab.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran