List Files/Folders
š§¾ Definition
The āList Files/Foldersā action in the Google Drive category allows you to search, filter, and retrieve files or folders stored within a Google Drive account. This action supports both personal drives and shared drives, and gives you the flexibility to narrow down results using parameters like file name, file type, advanced queries, corpora (data scope), and labels.
Key capabilities include:
- Searching by partial name match, MIME type, or custom query syntax.
- Filtering results to include or exclude trashed items, folders, files, or shared drive content.
- Controlling result size, pagination, and ordering (e.g., by name, last modified, or created time).
- Leveraging advanced Google Drive query language to target files based on metadata, folder hierarchy, shared state, and more.
This action is ideal for building workflows where document discovery, content processing, or automation on specific files/folders is required.
š Example Use Cases
1. Retrieve All Files in a Specific Folder
Use this action to list all files stored within a known folder by passing a query like 'folderId' in parents. This is useful when you want to process all contents of a given directory.
2. List Only Folders for Navigation
Filter results to return only folders (mimeType = 'application/vnd.google-apps.folder') to dynamically present users with a list of available directories for further selection or navigation.
3. Search Files by Partial Name
If you're unsure of the exact file name, use the File Name input to return all files and folders containing the specified keyword (e.g., āinvoiceā, āreportā) in their names.
4. Exclude Trashed Items for Clean Results
Enable Exclude Trashed Items to make sure you're only working with active, non-deleted filesāideal for maintaining accurate workflows that rely on valid inputs.
5. Fetch All Files Shared with Me
Use the corpora=user and sharedWithMe=true query pattern to list files that have been shared with the current user, especially helpful in team collaboration flows.
6. Sort Files by Most Recent Update
Use the Order By field with modifiedTime desc to retrieve the most recently edited filesāhelpful in approval flows or monitoring document changes.
7. Include Items from Both My Drive and Shared Drives
Toggle Include Items from Shared Drives and use corpora=allDrives to get a complete overview of files across all accessible drives.
š„ Inputs
1. Connection
The Google Drive connection that authorizes this action to access your files. Make sure the connected Google account has the appropriate permissions to view or query the target files or folders.
2. File Name
Returns only the files or folders whose names contain the specified value. This is a case-insensitive search and supports partial matches.Example: Entering "invoice" would match files like Invoice_2023.pdf, invoice_jan.xlsx, or Final_Invoice.txt.
3. Search For
Specifies the type of items to include in the results. You can choose from:
Filesā Only list individual file items.Foldersā Only list folders.Files and Foldersā Include both in the response.This helps narrow down the search scope and improves efficiency when you're only interested in one type.
4. Exclude Trashed Items
If enabled, the search results will omit files or folders that are in the Trash. This is useful to avoid listing obsolete or deleted items that should no longer be processed.
5. Query
A powerful field that allows advanced filtering using the Google Drive query language.You can create expressions like:
"mimeType='application/pdf'"ā Return only PDFs."'FOLDER_ID' in parents"ā Return items inside a specific folder."sharedWithMe"ā Return files shared with the user.
Combine multiple conditions usingandoror(e.g.,name contains 'report' and mimeType='application/vnd.google-apps.document').
6. Include Items from Shared Drives
When enabled, this includes results from both My Drive and Shared Drives (previously called "Team Drives").If disabled, only My Drive content is searched.
To fully utilize this with Shared Drives, make sure to also setcorpora=allDrivesand provide a valid Drive ID if needed.
7. Order By
Defines how the results are sorted. You can use one or more fields, separated by commas.Supported sort fields include:
createdTimenamemodifiedTimeviewedByMeTimequotaBytesUsedstarredfolder(folders first)
To sort in descending order, append desc.Example: folder,modifiedTime desc ā shows folders first, then files sorted by last modified time (newest first).
8. Corpora
Defines the grouping of files that the search applies to. Choose based on where the files reside:
userā Files the user created, opened, or that were shared directly with them.driveā Files inside a specific Shared Drive (you must provide a Drive ID).domainā Files shared across the userās organization domain.allDrivesā Searches across My Drive and all Shared Drives the user has access to.
ChoosingdriveorallDrivesrequires enabling Include Items from Shared Drives.
9. Spaces
Specifies where to search. Supported values:
driveā Standard files and folders in Google Drive.appDataFolderā Private app-specific data stored in the hidden app data folder.
This field is rarely changed unless your app explicitly stores files in appDataFolder.
10. Drive ID
If you're searching within a specific Shared Drive, provide its Drive ID here.
This is only necessary if
corporais set todriveorallDrives.You can find Drive IDs from prior steps or from the Drive's URL in your browser.
11. Include Labels
A comma-separated list of label IDs that should be included in the label information part of the response.This is useful if your organization uses Drive Labels for metadata tagging and you want to filter or view those labels.
12. Max Results
Specifies the maximum number of files or folders to return in one request.*Allowed values: 1 to 20,000.*Larger values will return more items per page but may take longer to process.
13. Page Token
Used for pagination. If the previous call returned a Next Page Token, you can use it here to fetch the next batch of results.Leave this empty for the first request.
š Common Query Patterns (for the āQueryā Field)
The Query field allows you to define advanced search filters to precisely target files or folders within Google Drive. It uses a structured query language (similar to SQL) supported by the Drive API v3. Here are some practical, commonly used patterns with explanations and real examples:
1. Find Items Within a Folder
Use this to return all items (files and/or folders) inside a specific folder.
'<folder-id>' in parents
Example:'1x93kY4xE3N8x8Hdhv5WfTXfQj0XsVw5z' in parentsā Use when listing files in a specific subfolder (e.g., "Project Documents").
2. Search by File Type (MIME Type)
Filter results by the fileās format using the mimeType field.
mimeType = 'application/pdf'
Example:mimeType='application/vnd.google-apps.folder'ā Lists only folders.
Example:mimeType='application/vnd.google-apps.spreadsheet'ā Lists only Google Sheets files.
š Full list of MIME types ā
3. Partial File Name Search
Find files whose names contain a certain word or pattern.
name contains 'invoice'
Matches files likeInvoice_2023.pdf,Q1_invoice.xlsx, etc.
Use = for exact match:
name = 'Final_Report.pdf'4. Find Recently Modified Files
You can filter by timestamps using modifiedTime, createdTime, etc.
modifiedTime > '2024-12-01T12:00:00'
Lists files modified after December 1, 2024, at 12:00 PM (UTC).Use ISO 8601 format (YYYY-MM-DDTHH:MM:SS).
5. Find Starred Files
Return only files the user has starred:
starred = true
Great for quickly listing important or flagged files.
6. Files Shared With Me
To find files that were shared with the current user, use:
sharedWithMe
Use this when building a workflow that depends on files you donāt own but have access to.
7. Exclude Trashed Files
Although there's a separate input for this, you can also use:
trashed = false
Adds an extra layer of protection to exclude deleted files.
8. Combine Multiple Conditions
You can use logical operators like and, or to combine multiple filters.
'name contains "Q2" and mimeType = "application/pdf" and trashed = false'
Finds all non-trashed PDFs with "Q2" in the filename.
9. Filter by Owner or Creator
Useful for listing files created or owned by a specific user.
'me' in ownersOr for a specific user:
'[email protected]' in owners
Helps target files you (or a teammate) own or created.
10. Filter Files Shared With a Domain
Lists files shared broadly within your organization.
sharedWithMe and visibility = 'domain'
Useful in enterprise settings to fetch team-shared resources.
š§ Tips for Building Better Queries
- Always enclose folder IDs and strings in single quotes (
'...'). - Use
andto narrow results (intersection),orto broaden (union). - Avoid ambiguous logic ā be explicit with your conditions.
- MIME types and folder IDs can often be pulled from earlier steps using tokens.
š Useful Resources
Note on No Results / More Reliable ResultsIf you've correctly configured the query and filters but still don't see the expected files, it's often due to limited search scope.
For most reliable and comprehensive search results, especially in organizations using shared drives:
- Set
Corporato'allDrives'ā This includes files from both My Drive and Shared Drives.- Enable
Include items from shared drivesThese settings ensure the search covers all drives the user has access to ā including team drives, shared folders, and personal files ā reducing the chance of missing items due to scope limitations.
š© Outputs
When the action runs, it returns structured and detailed information about all the files and folders that match your specified search filters. These outputs are especially useful for follow-up actions like downloading files, checking ownership, verifying file types, or managing shared items.
ā
Result Count
Indicates the number of files and/or folders returned in the current response.
Why it matters:Helpful for reporting or validation ā e.g., āDid I get 1 file or 50?ā, or āDid any files match the criteria?ā
Example Output:
"resultCount": 3ā
Files/Folders
This is a list of file/folder objects, each containing detailed metadata. These are the actual items retrieved based on your filters or queries. Below are the most important fields within each item:
š ID
A unique identifier for each file or folder in Google Drive.
Example:
"id": "1CaeTxgpaf_PhY6n1y_u4zo0SqtauT4Y9"š Drive ID
If the file or folder belongs to a shared drive, this contains the shared drive's ID.
Example:
"driveId": "0AOx123abc456Uk9PVA"š Name
The name of the file or folder as it appears in Google Drive.
Example:
"name": "Annual Report 2025.pdf"š MIME Type
Specifies the format/type of content ā distinguishes between folders and different file formats (PDFs, Docs, images, etc.).
Examples:
- Google Doc:
application/vnd.google-apps.document - PDF:
application/pdf - Folder:
application/vnd.google-apps.folder
š Version
Shows the current version number of the file ā useful if you're monitoring or syncing updates.
Example:
"version": 5š Web View Link
A shareable URL that opens the file/folder in the Google Drive web interface.
Example:
"webViewLink": "https://drive.google.com/file/d/1CaeTxgpaf_PhY6n1y_u4zo0SqtauT4Y9/view"š Size
The size of the file in bytes. This is only returned for files (not folders).
Example:
"size": 31524762 // (~30 MB)š Trashed
Indicates whether the file or folder has been moved to trash.
Example:
"trashed": falseš Explicitly Trashed
Specifies whether the item was intentionally trashed by a user, vs. implicitly removed.
Example:
"explicitlyTrashed": falseš Created Time
Timestamp for when the file or folder was originally created.
Example:
"createdTime": "2025-07-31T14:16:36.979+00:00"š Modified Time
Timestamp of the last time the item was modified.
Example:
"modifiedTime": "2025-08-01T07:07:51.141+00:00"š Shared
A boolean that shows whether the item has been shared with other users.
Example:
"shared": trueš Parents
List of parent folder IDs ā helps track the itemās exact location within Drive.
Example:
"parents": ["0Bz6FwRMcU7BoX3NmYjR5"]š Owners
Details of the user(s) who own the file, including name and email.
Example:
"owners": [
{
"displayName": "Jane Doe",
"emailAddress": "[email protected]"
}
]š Permissions
A list of sharing permissions, including users, their roles (owner, reader, writer), and emails.
Example:
"permissions": [
{
"role": "writer",
"emailAddress": "[email protected]",
"type": "user"
},
{
"role": "owner",
"emailAddress": "[email protected]",
"type": "user"
}
]ā
Next Page Token
If the result has more items than the current page allows (Max Results), this token lets you fetch the next batch.
How to use:Use this token in the Page Token input field in a follow-up call to continue retrieving the remaining results.
Example:
"nextPageToken": "~!!~AI9FV7SGky-..."š§Ŗ Example: List All Files Inside a Specific Folder
šØ Scenario
You have a Google Drive folder named "Monthly Reports", and you want to automatically fetch all the files inside that folder ā perhaps to process, email, or archive them.
š ļø Step-by-Step Setup
-
Find the Folder ID FirstUse the āFind File/Folderā action to search for the folder by name:
- This action will return the folder's ID, which you'll need for the next step.
-
List Files Inside the FolderNow use the āList Files/Foldersā action and configure it like this:
-
š¹ Query:
'FOLDER_ID' in parentsReplace
'FOLDER_ID'with the ID you retrieved in the previous step. -
š¹ Search for:
Files(or leave empty for both files and folders) -
š¹ Exclude trashed items:
True -
š¹ Corpora:
allDrives(recommended for most reliable search) -
š¹ Include items from shared drives:
True(especially if the folder is in a shared drive)
-
-
Use the Output
- Youāll get a list of files inside that folder, along with their metadata (name, size, link, owner, etc.)
- You can loop over them, send them via email, move them, download them, or pass them to another step.
š Tip
If your folder is part of a Shared Drive, itās essential to:
- Set Corpora to
"allDrives" - Enable Include Items from Shared Drives
This ensures you donāt miss anything due to visibility restrictions.
ā
Best Practices
Follow these best practices to get the most reliable and accurate results from the List Files/Folders action:
1. Always Use a TargetedQuery When Possible
Query When PossibleTo avoid retrieving unnecessary data and speed up the action:
- Use queries like
'FOLDER_ID' in parentsto target specific folders. - Combine filters like
mimeType contains 'pdf'orname contains 'invoice'to refine results.
2. SetCorpora to allDrives for Broad Coverage
Corpora to allDrives for Broad CoverageTo ensure your search includes both My Drive and Shared Drives, use:
Corpora:allDrivesInclude items from shared drives:True
This avoids missing files due to Drive-specific scoping.
3. Use Pagination for Large Results
If you're retrieving many files (e.g., more than 100), use the Next Page Token in a loop to fetch the next batch of results.
4. Limit Max Results to Optimize Performance
If you only need a few results (e.g., latest file), set Max Results to a low value like 1 or 5 to reduce execution time and improve efficiency.
Updated 2 months ago
