recursively list all the files problems

5 views
Skip to first unread message

Tesla2020

unread,
Sep 8, 2014, 12:09:04 AM9/8/14
to google-drive...@googlegroups.com
I am trying to recursively list all the files and files of the sub folders in a specific google drive folder

my code are the following

def list_file(parent):
  result
= service.files().list(q= "'%s' in parents and trashed=false" % parent).execute(http=decorator.http())
  tasks
= result.get('items', [])

 
for f in tasks:
   
if f['mimeType'] == 'application/vnd.google-apps.folder':
      list_file
(f['id'])

 
return tasks

tasks
= list_file('the specific folder ID')

and the problem is that it would only return list of files and folders directly under the the specific folder ID and not the sub folders and the files in the sub folders.

anyone knows how I should fix fix my code to make it work? Thanks

or is there any better approach to list all the files and files of the sub folders under a specific folder in google drive using its API? would be great if someone can share the code.

Thanks in advance.


Reply all
Reply to author
Forward
0 new messages