1

I'm doing a python script which periodically upload a folder to Google Drive, but got stuck when I had to load subfolders. Is there any way to upload an entire folder?

Maybe with a loop but I have no idea how to do it.

Below is an example of a folder to upload:

root\
root\image.png
root\Folder1\text.txt
root\Folder1\music.mp3
root\Folder2\MyFolder\homeworks.txt
root\Folder2\Something\something.txt

I'm using PyDrive.

martineau
  • 119,623
  • 25
  • 170
  • 301
SAL
  • 547
  • 2
  • 8
  • 25
  • Isn't your Google drive mapped to some sort of virtual drive on your system? If so, you should be able to just copy the folder to it like you would to any other drive attached to it. – martineau Aug 24 '20 at 23:59

1 Answers1

-1

A simpler workaround is to just zip the file:

shutil.make_archive('data', 'zip', 'output')
file = drive.CreateFile({'title': 'data.zip'})
file.SetContentFile('data.zip')
file.Upload()
Jeff Bezos
  • 1,929
  • 13
  • 23