1

This is a potential duplicate of: Google Drive API: list files with no parent (but I hope to restate it clearer).

How can I best use the Google Drive API to list files without parents? i.e. where parents = [].

According to https://developers.google.com/drive/web/search-parameters the only operator allowed on "parents" is "in", while I'm looking to query where len(parents) = 0.

I already have a brute force approach where I then manually compare the parents field to see if it's zero-length, but it's quite slow.

Community
  • 1
  • 1
Slipstream
  • 385
  • 3
  • 10
  • 2
    wouldnt they be children of root? (haven't tried) – Zig Mandel Aug 04 '15 at 16:27
  • Nope. There are some files which are children of root, which I know about. But I'm interested in finding the ones owned by users which aren't children of root (because they're otherwise invisible). Doing this the slow way I find 900+ files for the current user. – Slipstream Aug 04 '15 at 16:30
  • i really doubt its possible to find those. they are problematic in the drive scheme of things and in the past ive only been able to find them by searching by file title. i had a support incident with drive once which caused many files to go parentless and google support didnt know how to find them other than by trying to guess their title. – Zig Mandel Aug 04 '15 at 16:32
  • I'd like to look into this. Do you have a sure way how to create (preferably manually on 'drive.google.com') files like these? – seanpj Aug 04 '15 at 16:33
  • @ZigMandel it's definitely possible to find them. I've got an app which finds them, I'm just looking for a more efficient way of doing it. – Slipstream Aug 04 '15 at 16:40
  • @seanpj The best way I know of creating them is to have three users and a folder shared between them, one user owns the folder, the second creates a file in the folder and the third then deletes the folder. Because the third user doesn't own the file, it can't trash it, but it also doesn't have anywhere new to live in the second users root so it just floats. NB: I can't actually test this right now because I don't have access to 3 users. Anyone else? – Slipstream Aug 04 '15 at 16:40
  • yes of course its possible by traversing the entire drive. obviously i meant its not possible in an efficient way. – Zig Mandel Aug 04 '15 at 16:41
  • and yes the way to create them is a good way and has happened to me many times, including one time where a bug in the google drive sync windows program caused a lot of my files to float like that. google support did not have a way to find them themselves. – Zig Mandel Aug 04 '15 at 16:43

0 Answers0