Colab drops every uploaded file into one folder, and the runtime wipes it when you disconnect. This guide shows you how to build a tidy folder structure, move uploads into the right place and mount Google Drive so your work survives. It suits beginners who can run a cell but have never organised a Colab session.
YouTube video: How to Organize Your Files in Google Colab!
Caption availability is unknown. Check the CC control in the YouTube player.
- Video length
- 6 min 30 s
- Time to do it
- 15 minutes
- Difficulty
- Easy
- Steps
- 8
What you need
Steps
Open a new notebook at colab.research.google.com and sign in with your Google account. Wait a few seconds for the runtime to connect.
Click the folder icon in the left sidebar to open the Files pane. It shows /content, the working folder for the current session.
Create a project folder with a cell like!mkdir -p /content/project/data. The -p flag builds parent folders and does not error if the folder already exists.
Click the refresh icon in the Files pane and check the new folder appears. If it does not, run the cell again and look for an error message.
Upload files with the upload icon in the Files pane, or move existing ones with!mv old.csv /content/project/data/ to keep the top level clean.
Change into the folder with %cd /content/project so relative paths like data/old.csv work in every later cell.
Build paths with pathlib instead of typing strings: from pathlib import Path, then DATA = Path("/content/project/data"). Change one line to move the whole notebook.
Mount Google Drive with from google.colab import drive and drive.mount('/content/drive'). Work inside a folder under MyDrive so files outlive the session.
Tips and common mistakes
Everything in /content is deleted when the runtime disconnects, so copy anything you want to keep into Drive or download it.
Avoid spaces and special characters in folder and file names, since they break shell commands in Colab.
Use one folder per project with data, output and notebook files kept separate.
Do not nest folders more than two or three levels deep, as long paths get hard to read in cells.
Questions
Do files I create in Colab stay saved?
Only if they sit in mounted Google Drive or you download them. Files in /content belong to the temporary runtime and disappear when it ends.
How do I delete a folder in Colab?
Run!rm -r /content/project in a cell. Check the path first, because there is no undo and the folder goes immediately.
Why does my file vanish after reconnecting?
Colab gave you a fresh machine, so the old /content folder is gone. Mount Drive at the start of every session and keep your files there.
The notes are drafted automatically from video details and general task knowledge. How the guide was prepared
Report a correction


