Pushkar Kathayat
Pushkar Kathayat

Reputation: 47

**How to list the contents of Multiple folder in Python Google Drive API?

I am trying to programmatically list the contents of multiple folders. But somehow unable to put variable in

queryt = f'{parent_folder_id} in parents'
while True:
    response = service.files().list(q=f'{queryt}',
                                    spaces='drive',
                                    fields='nextPageToken, files(id, name)',
                                    pageToken=page_token).execute()

The first variable q in service.files().list doesn't seem to accept variable but accepts direct values.

Is there any way to solve this issue?

Thanks

Upvotes: 0

Views: 132

Answers (1)

Pushkar Kathayat
Pushkar Kathayat

Reputation: 47

For anyone looking for the above issue can try.

        response = gdrive_service.files().list(
        q="parents in '"
          + folder_id + "' and trashed =""false",
        fields="nextPageToken, ""files(id, name)",
        pageSize=400).execute()

Thank you

Upvotes: 1

Related Questions