Skip to main content

Notifications

Community site session details
Power Automate - Building Flows
Answered

List Files in Folder only if the file extension is zip

Like (0) ShareShare
ReportReport
Posted on 25 Oct 2023 16:20:15 by 578

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.

  • Verified answer
    creativeopinion Profile Picture
    10,406 Super User 2025 Season 1 on 25 Oct 2023 at 17:44:29
    Re: List Files in Folder only if the file extension is zip

    @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

    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.

    creativeopinion_1-1698255480945.png

     

    Count Files Returned

    Add a Compose action after to count the number of items returned. Use the length() function.

    creativeopinion_2-1698255631273.png

    Click on the Dynamic content tab and insert the value dynamic content from the List files in folder action.

    creativeopinion_3-1698255667120.png

    Press OK.

    creativeopinion_4-1698255706098.png

    Run a test. Verify the output of the Compose action. It should display the number of files only. 

    creativeopinion_5-1698255734917.png

     

    Add an Additional Condition to the Filter Array

    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.

     

    creativeopinion_7-1698255964220.png

    creativeopinion_8-1698256008620.png

     

    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). 

     

    creativeopinion_6-1698255928183.png

    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.

    creativeopinion_14-1698256117757.png

     

    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.

     

    creativeopinion_13-1698256099196.png

     

    Paste the expression back into the Filter Array action. 

     

    creativeopinion_15-1698256136650.png

     

    Adjust the Compose Action Expression

    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.

     

    creativeopinion_17-1698256343555.png

     

    Run another test. Verify the number of files returned. It should display the number of zip files in your OneDrive folder.

     

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response!

    👉Watch my tutorials on YouTube
    👉Tips and Tricks on TikTok

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 59

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 47 Super User 2025 Season 1

#3
rzaneti Profile Picture

rzaneti 29 Super User 2025 Season 1

Overall leaderboard
Loading started
Loading started