Find File

Last Updated: Nov 26, 2021


Use this function to look for files on a Google Drive instance.


Find File (query, number_of_records, private_key, client_email)


Input Parameter Name Description
query Search query
For more information, refer to the below table Search Query Samples
number_of_records Number of matching records to be returned
private_key Private key of the service account
client_email Email ID of the service account


Return Value Description
  • On Success returns 1, id||filename
  • On Failure returns 0, Error Message


Find File (name = invoice, 2, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–,

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID, looks for 2 files with the name invoice.
    Returns id1||filename1, id2||filename2 on finding the file.

Search Query Samples

What to query Examples
Files with the name hello name = hello
Files with a name containing the words hello and goodbye name contains hello and name contains goodbye
Files with a name that does not contain the word hello not name contains hello
Folders that are Google apps or have the folder MIME type mimeType = application/
Files that are not folders mimeType != application/
Files that contain the text important and in the trash fullText contains important and trashed = true
Files that contain the word hello fullText contains hello
Files that do not have the word hello not fullText contains hello
Files that contain the exact phrase hello world fullText contains hello world
Files with a query that contains the ** character (e.g., \authors) fullText contains \authors
Files with ID within a collection, e.g. parents collection 1234567* in parents
Files in an Application data folder in a collection appDataFolder* in parents
Files for which user has write permission* in writers
Files for which members of the group have write permission* in writers
Files modified after a given date modifiedTime > 2012-06-04T12:00:00 // default time zone is UTC
Files shared with the authorized user with hello in the name sharedWithMe and name contains hello
Files that have not been shared with anyone or domains (only private, or shared with specific users or groups) visibility = limited
Image or video files modified after a specific date modifiedTime > 2012-06-04T12:00:00 and (mimeType contains image/ or mimeType contains video/)

This list is not exhaustive.

To view all the Google Drive functions, click here.

Did you find what you were looking for?