web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Is there a simple way ...
Power Automate
Answered

Is there a simple way to loop through files in a sharepoint folder

(1) ShareShare
ReportReport
Posted on by 6
Hello everyone, basically I want to loop through a sharepoint folder with csv files, and if the file name contains a keyword, pick that file and count the number of rows in the file. Is there an easy way to do this? I cant find much online, thanks!
Categories:
I have the same question (0)
  • Verified answer
    leo85 Profile Picture
    617 on at
    Hi,
    is your problem to loop through the SharePoint list or through the file?
     
    To loop through the list you do the following steps:
    1. Create an action "Get files (properties only)" from the SharePoint Connector
    2. Create a "Apply to each" loop.
    3. Add the "body/value" attribute from the "Get files" action to the input of the loop.
     
    If you want to count the number of rows in a csv file. This is not trivial, but you could try the following.
    1. Create an action "Get file content" form the SharePoitn connector.
    2. Create a "Compose" action with the following expression "split(body('Get_file_content'),decodeUriComponent('%0A'))". This splits the content of the file at every new line.
    3. Create another "Compose" action with the following expression "length(outputs('Compose'))". This counts the number of items in the array created by the action before.
    The number of rows in the CSV file should be in the last compose action.
     
    Regards
    -----------------------------------
    If my answer solved your issue, please mark it as a solution.
    If what I wrote helped you, please give it a thumbs up.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 523

#2
Valantis Profile Picture

Valantis 318

#3
David_MA Profile Picture

David_MA 235 Super User 2026 Season 1

Last 30 days Overall leaderboard