How do I download multiple files or an entire folder from Google Colab?

tetedp picture tetedp · May 21, 2018 · Viewed 41.8k times · Source

Currently, I can download files as individual files with the command

files.download(file_name)

I also tried uploading them to the drive with the below code snippet but it is uploading them as individual files.

uploaded = drive.CreateFile({'title': file_name})
uploaded.SetContentString('Sample upload file content')
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))

How can I download multiple files as a folder to my local computer? Or how can I upload these files as a folder to my google drive?

Answer

Shashank Mishra picture Shashank Mishra · Sep 28, 2018

I have created a zip file:

!zip -r /content/file.zip /content/Folder_To_Zip

Than I have downloded that zip file:

from google.colab import files
files.download("/content/file.zip")