0

I have a difficulty to find a file in my team drive because i also have file from trash.

There is my current code :

filename = 'name'
file_list = drive.ListFile({
    'q':f"title contains '${filename}' and mimeType='application/pdf'",
    'supportsAllDrives':True,
    'corpora': "teamDrive",
    'teamDriveId': 'ID',
    'supportsTeamDrives' :True,
    'includeItemsFromAllDrives':True,
}).GetList()
print(len(file_list))

but i have 3 files because 2 are in the trash.

Thank you

Alexia
  • 19
  • 3
  • In your script, in order to exclude the files in the trash box, please use `trashed=false` like `f"title contains '${filename}' and mimeType='application/pdf' and trashed=false"`. If you want to retrieve only the file list in the trash box, please use `trashed=true`. [Ref](https://developers.google.com/drive/api/guides/search-files) – Tanaike May 31 '22 at 08:59
  • Thank you for replying and testing it. I'm glad your issue was resolved. Thank you, too. In this case, I found the duplicated question. So., I flagged it as a duplicated question. – Tanaike May 31 '22 at 09:07

0 Answers0