Skip to content

Instantly share code, notes, and snippets.

@oguzhari
Last active September 15, 2022 19:41
Show Gist options
  • Select an option

  • Save oguzhari/907117bba659a5eabce9fc80f7ee2981 to your computer and use it in GitHub Desktop.

Select an option

Save oguzhari/907117bba659a5eabce9fc80f7ee2981 to your computer and use it in GitHub Desktop.
def save_files():
gauth = GoogleAuth()
create_cred_file()
gauth.LoadCredentialsFile('mycreds.txt')
drive = GoogleDrive(gauth)
folder_name = 'test' # Please set the folder name.
folders = drive.ListFile(
{
'q': "title='" + folder_name + "' and mimeType='application/vnd.google-apps.folder' and trashed=false"}).GetList()
for folder in folders:
if folder['title'] == folder_name:
for created_file in created_files:
file = drive.CreateFile({'parents': [{'id': folder['id']}]})
file.SetContentFile(created_file)
file.Upload()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment