Search

Find File

Last Updated: Nov 26, 2021

Articles

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

Syntax

Find File (query, number_of_records, private_key, client_email)

Parameters

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

Returns

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

Sample

Find File (name = invoice, 2, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–, name@project-id.iam.gserviceaccount.com)

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID name@project-id.iam.gserviceaccount.com, 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/vnd.google-apps.folder
Files that are not folders mimeType != application/vnd.google-apps.folder
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 test@example.org has write permission test@example.org* in writers
Files for which members of the group group@example.org have write permission group@example.org* 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?