I am trying to get all files that are in a specific section of Google Drive (The Drive Section).
Those are the files I am looking for:
You can see a folder named Projet 3
and a file named Processus TP2 questions
. In the folder I only have one file.
But when I try to list all the files, I get thousands of files. If I search for them using the search bar on top of Google Drive, it finds them, but I have no idea where they are (maybe Gmail attachement?).
This is my search query:
FileList result = service.files().list()
.setQ("mimeType != 'application/vnd.google-apps.folder'
and trashed = false")
.setSpaces("drive")
.setFields("nextPageToken, files(id, name, parents)")
.setPageToken(pageToken)
.execute();
How can I list only the files I can see in my Drive Section/Folder on the web UI?
Thank you very much.
Create a new Google Sheets spreadsheet or open an existing spreadsheet where you want the list saved. Here's a tip: You can quickly create a new Google Sheets spreadsheet using https://spreadsheet.new. Create a sheet in the spreadsheet called "Files". The list of files will be written to the sheet.
3. Right-click on any one file and select “Share…” 4. On the following screen you should be able to see the number of files you have in the folder in the brackets next to the words “Share with others.”
Use "parents" property in your query, like this:
FileList result = service.files().list()
.setQ("'root' in parents and mimeType != 'application/vnd.google-apps.folder' and trashed = false")
.setSpaces("drive")
.setFields("nextPageToken, files(id, name, parents)")
.setPageToken(pageToken)
.execute();
If you want to list the contents of a specific folder rather than root - use that folder's id instead of 'root' in the query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With