Get Folder & item Child Count SharePoint Library

By
Last updated:

Get Folder & item Child Count SharePoint Library

Organizations using SharePoint Online often need to retrieve folder and file counts from document libraries for reporting, validation, or automation purposes. This use case allows users to select a folder or file in a SharePoint document library and dynamically fetch the number of files and subfolders within that folder using Power Automate.

Business Scenario

A company manages a large SharePoint document library for storing project-related files. Project managers need a quick way to check how many files and subfolders exist within a specific folder without manually counting them. By using Power Automate, they can select a folder in SharePoint and instantly retrieve the count of items within it.

Functional Requirements

User selects a folder or file in SharePoint and triggers the flow manually.
The flow retrieves all items (files and folders) within the selected folder using SharePoint APIs.
Filters and counts the number of files and subfolders separately.
Returns the folder and file count to the user via an email, Teams message, or PowerApps response.

Get Folder & item Child Count SharePoint Library

SharePoint list named “DocumentCountList”, which contains columns:

  • Title (Possibly an identifier)
  • FolderCount (Number of folders)
  • Item Child Count_2 (Number of files/items)

Step 1: Create a Power Automate Flow

  1. Go to Power Automate (https://flow.microsoft.com)
  2. Click Create → Automated Cloud Flow
  3. Select “For a selected file” (SharePoint trigger).
  4. Provide your Site Address and Library Name.

initializing two integer variables in Power Automate:

  1. foldercount (Default value: 0) – To store the count of folders.
  2. itemcount (Default value: 0) – To store the count of items/files.

Get File/Folder Properties

  • Action: “Get file properties” (SharePoint)
    • Site Address: Select the SharePoint site.
    • Library Name: Choose the document library.
    • Id: Use ID from the trigger.

List Folder Contents

  • Action: “List folder” (SharePoint)
    • Site Address: Select the SharePoint site.
    • File Identifier: Use the Identifier from “Get file properties” output.

“Apply to each” Loop

  • Iterates through the Body output from the “List folder” action.

Condition: Check if the item is a folder

  • Uses the IsFolder property.
  • If IsFolder is true, it is a folder.
  • If IsFolder is false, it is a file.

Increment Counters Based on Condition

  • If Yes (Folder Found):
    • Increment foldercount by 1.
  • If No (File Found):
    • Increment itemcount by 1.

Update the item back in sharepoint

Select Item And Run flow

✨ Thanks for reading! ✨

I hope you found this blog on the Microsoft Power Platform helpful! From Power Apps, Power Automate (Cloud & Desktop), Canvas Apps, Model-driven Apps, Power BI, Power Pages, SharePoint, Dynamics 365 (D365), Azure, and more, I cover a wide range of topics to help you harness these powerful tools. Don’t miss out on future tips, tutorials, and insights—hit that subscribe button to get the latest posts right to your inbox. 💌💬 I’d love to hear your thoughts! Drop a comment below with your questions, ideas, or feedback—let’s get the conversation started!🔗 Let’s connect and grow together!


Follow me, Ravindra Jadhav, on your favorite platforms for even more content and updates on Microsoft Power Platform and related technologies:

💼 LinkedIn – Let’s network and share ideas!

💻 GitHub – Explore my projects and code.

🐦 Twitter – Stay updated with quick tips and industry news.

📺 YouTube – Watch tutorials and deep dives on Power PlatformPower AppsPower Automate, and more! Let’s build something amazing together with Power Platform and Azure! 🚀 

Get Folder & item Child Count SharePoint Library

List of item in SharePoint Folder

Count Files & Folders in SharePoint

SharePoint Library Item Counter

Power Automate: Folder & File Count

Automate SharePoint Item Count

Track Document Count in SharePointFile & Folder

Counter FlowSharePoint Folder Statistics

Document Library Count Automation

Power Automate SharePoint Insights

Get File & Folder Count Instantly

Learn how to count files and folders in a SharePoint document library using Power Automate. This step-by-step guide walks you through automating the process of retrieving folder and item counts, storing them in a SharePoint list, and optimizing your document management. Boost productivity with Power Automate and SharePoint automation. Read now for a detailed tutorial!

Primary Keywords (High Impact)

  • SharePoint file and folder count
  • Power Automate SharePoint list update
  • Automate SharePoint document count
  • Count files in SharePoint library
  • Power Automate file counter

Secondary Keywords (Supportive & Long-tail)

  • How to use Power Automate with SharePoint
  • Get folder count in SharePoint using Power Automate
  • Automate document tracking in SharePoint
  • SharePoint list automation tutorial
  • Step-by-step Power Automate guide

2 thoughts on “Get Folder & item Child Count SharePoint Library”

Leave a Comment