List files in folder in Google Drive Connector(Power Automate Cloud flows)
This action retrieves a list of files and folders stored in a specified folder in Google Drive.
How to use
Select the "Google Drive" connector when adding steps to the flow.
Select "List files in folder" from the "Actions" menu.
Set parameter.
Parameter | Default | Description |
---|---|---|
Folder id | Required field | Select a file with the directory icon on the right. It looks like a folder path, but it is only a display and the substance is an ID. If you create a folder with the same name after deleting the specified folder, it will be treated as a different folder. (You will need to reassign it.) |
Specify a "Control" connector for the new step.
Select "Apply to each" from the "Actions" menu.
Specify the "body" of the dynamic content in "Select an output from previous steps".
This will cause the action specified in "Apply to each" to be repeated the number of times for the files and folders stored in the folder.
(Each iteration will target a different file or folder)
Dynamic content
Typical dynamic content for files subject to repetition is as follows
Additional information about the file or folder can be obtained.
Name | Type | Description |
---|---|---|
Id | Text | Identifier of the file/folder. |
Name | Text | File and folder names. |
Path | Text | Full path. It is difficult to use as is, so string manipulation is often required. |
MediaType | Text | MINE type of file. |
LastModifiedBy | Text | User name of the last updater. |
LastModified | Text(Datetime) | Last updated. |
Size | Number | The number of bytes in the file. |
Only additional information can be obtained.
If you need the file content, which is the content of the file, use the "Get file content using id" action to get it.
Example of use: Delete all files in a folder.
For example, to delete all files in a folder, do this.
Note that since there is no action to delete a folder, only files can be deleted.
To do so, first select "Condition" from "Control" in "Apply to each".
Next, in "Condition", specify "IsFolder" for dynamic content on the left side and "true" on the right side.
Then add a "Delete file" action in the "If No" section,
"Id" of dynamic content to the file.
This will result in a flow that deletes the entire contents of the folder.
Since the lower levels of the hierarchy are not covered, you will need to add a "List files in folder" to the "If yes" case for the required level.
For those who want to learn Power Automate Cloud flow effectively
The information on this site is now available in an easy-to-read e-book format.
Or Kindle Unlimited (unlimited reading).
You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Power Automate Cloud flow to streamline your workflow.
Discussion
New Comments
No comments yet. Be the first one!