סתיו לוי
סתיו לוי

Reputation: 21

Create a folder google drive in specific path

i have used the script of create a folder from this link: Create a folder and it's work.

file_metadata = {
    'name': 'Invoices',
    'mimeType': 'application/vnd.google-apps.folder'
}
file = drive_service.files().create(body=file_metadata,
                                    fields='id').execute()
print 'Folder ID: %s' % file.get('id')

How can i create the folder in specific path ?

Upvotes: 2

Views: 152

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116948

You need to add the fileId of the folder you want to create your new folder in as parents parameter in the metadata.

file_metadata = {
    'name': 'Invoices',
    'mimeType': 'application/vnd.google-apps.folder'
    'parents': 'FOLDERID'
}
file = drive_service.files().create(body=file_metadata,
                                    fields='id').execute()
print 'Folder ID: %s' % file.get('id')

Upvotes: 1

Related Questions