I'm building a Manually triggered flow that loops through a OneDrive folder and gets the files within it. The issue is that the folder may contain files and folders that I don't need any information from. Is there a way to limit the scope (filter) of List files in folder to files with a specific file extension? In my case it would be only Zip files.
Thanks in advance.
@emfuentes27 Instead of looping through each file returned to check if the item is a) a file and b) is a zip file, it's more efficient to use a Filter Array action.
To learn more about how to use the Filter Array action, please refer to this recent YT Tutorial I uploaded.
Add a Filter Array action to your flow. In the From field, insert the value dynamic content from the List files in folder action.
In the first value field, insert the Is Folder? dynamic content. Leave the operator as is equal to and in the second value field enter false.
Add a Compose action after to count the number of items returned. Use the length() function.
Click on the Dynamic content tab and insert the value dynamic content from the List files in folder action.
Press OK.
Run a test. Verify the output of the Compose action. It should display the number of files only.
You will need to add an additional condition to your Filter Array action to filter out the zip extension. This section of my tutorial covers how to add an additional condition.
Click on the Edit in Advanced Mode button, and copy the expression and paste it into a text editor.
Press edit in basic mode and replace the Is Folder? dynamic content with the Name dynamic content. This dynamic content returns the file name with an extension. You can use the contains or ends with operator (doesn't matter—you choose).
Click on edit in advanced mode and copy the expression and paste it into the text editor (on the second line. Ensure that you add a comma after the first expression to separate them both.
Then you will need to delete the '@' symbol from the second line. Wrap the entire expression in an and() function. Copy this expression to your clipboard.
Paste the expression back into the Filter Array action.
Now that you are using a Filter Array action to filter out your files. You will need to adjust the Compose action that is returning the number of files returned.
Replace the content between the length() function brackets with body outputs from the Filter Array action.
Run another test. Verify the number of files returned. It should display the number of zip files in your OneDrive folder.
Hope this helps!
stampcoin
51
Michael E. Gernaey
39
Super User 2025 Season 1
rzaneti
22
Super User 2025 Season 1