Depending on how many files are returned from the List files in folder action. It's always best practice to filter out the files you want to loop through first before you loop through them.
The way your flow is currently structured can be inefficient especially if you have a lot of files since you are looping through every file returned and running a condition check to see if the file matches your criteria. Instead, use a Filter Array action to filter out files that you want to delete.
If you aren't familiar with how to use the Filter Array action, check out this YT Tutorial I've linked at the bo. Filter out the files with a .txt extension by using the ends with operator.
Tip: Ensure you add a Compose action to return the count of files returned before you continue on with your flow. I demonstrate how to do this in this section of the tutorial.
If you still run into issues after watching the tutorial, ensure that you toggle off the New Designer and click each action to expand it. Upload a screenshot of your flow in edit mode.
In this video tutorial I’ll show you 3 practical ways to use the Filter Array action and how to use it properly.
1️⃣ Cross-Referencing Data
2️⃣ Filtering by Key
3️⃣ Substring Matching
Did you know that the Condition action has a limit of 10 conditions? Although it might look like the Filter Array action can only accept one condition—this is not true. By using the advanced mode you can enter multiple conditions into a Filter Array action with an expression.
IN THIS VIDEO:
✅ 3 Ways to Use the Filter Array Action
✅ How to use the Scope Action to Group Actions
✅ How to Check the Number of Items returned from a Filter Array Action
✅ How to Cross-Reference Data in Excel with a SharePoint List
✅ How the Filter Array Action Works
✅ How to Access the Dynamic Content from a Filter Array Action
✅ How to Filter Items by a Key
✅ How to Filter Items by Matching a Substring
✅ How to Use Multiple Conditions in a Filter Array Action
Hope this helps!
Consider giving me a
❤️ if you liked my response!
👉 Level up your Power Automate skills by checking out my tutorials on
YouTube
👉 Tips and Tricks on
TikTok and
Instagram