Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Mount Google Drive in Colab by running the following code:
from google.colab import drive
drive.mount('/content/drive')
  1. Navigate to the directory that contains the folder you want to transfer using the following command:
%cd '/content/drive/MyDrive/<directory>'

Replace <directory> with the path to the directory containing the folder you want to transfer.

  1. Use the following command to zip the folder and its subfolders:
!zip -r <foldername>.zip <foldername>

Replace <foldername> with the name of the folder you want to transfer.

  1. Once the zip file has been created, copy it to Google Drive using the following command:
!cp <foldername>.zip '/content/drive/MyDrive/<destination>'

Replace <foldername> with the name of the zip file you just created and <destination> with the path to the directory in Google Drive where you want to save the zip file.

  1. Unzip the file in Google Drive using the following command:
!unzip '/content/drive/MyDrive/<destination>/<foldername>.zip' -d '/content/drive/MyDrive/<destination>/<foldername>'

Replace <destination> and <foldername> with the appropriate names and paths. This will extract the contents of the <foldername>.zip file into a new folder with the same name as the original folder.

  1. Verify that the folder and its subfolders have been transferred successfully to Google Drive.