How to make the contents of two colab files same

I am learning python programing using Google Colab. When i open two google colab files from the same account, the folders in content drive are different. I wanted to know that how can we make the two Content Folder of the two Google Colab files same. Thanks


Solution 1:

Each Google Colab session allocates different resources from Google Cloud. You cannot combine them. Instead, you can connect the notebook to Google Drive account, where you can create a folder and manage its contents.

Step 1: Connect to Google Drive:

from google.colab import drive
drive.mount('/content/drive')

Step 2: Create a folder:

!cd /content/drive/My Drive
!mkdir mydirectory

Step 3: Move to the newly created directory and start working there:

!cd mydirectory

After this, any OS-related operations (create, update, delete files, etc.) you perform will take place in this directory.

You can also create a Jupyter Notebook within this directory and work with that notebook, although that is not strictly necessary.