List files in folder in Google Drive Connector(Power Automate Cloud flows)


Japanese version.

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.

Folder idRequired fieldSelect 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.

IdTextIdentifier of the file/folder.
NameTextFile and folder names.
PathTextFull path.
It is difficult to use as is, so string manipulation is often required.
MediaTypeTextMINE type of file.
LastModifiedByTextUser name of the last updater.
LastModifiedText(Datetime)Last updated.
SizeNumberThe 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.



Google Drive Connector