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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 470

#2
Haque Profile Picture

Haque 416

#3
David_MA Profile Picture

David_MA 344 Super User 2026 Season 1

Last 30 days Overall leaderboard