How to Count Folders, Document Sets, and Documents in SharePoint
Question details
The user wants to find a method to separately count the total number of folders, document sets, and documents within a SharePoint library.

- Product
- SharePoint
- Device & OS
- not provided
- Scenario
- Analyzing and auditing the contents of a SharePoint document library to understand the exact distribution of different item types.
- Observed behavior
- The standard SharePoint ItemCount property only provides a combined total of all items in the library and does not separate the counts by FSObjType (folders, document sets, or documents).
Ensure you have access to Microsoft Power Automate with adequate permissions to connect to your SharePoint site and read the target document library.
Use Power Automate to Count Items by Type
Since SharePoint does not expose separate totals through its standard interface, you can build a Power Automate flow to retrieve items, evaluate their types, and maintain distinct counts.
Power Automate can iterate through all the items in a SharePoint library. By checking the properties of each item—specifically the FSObjType (File System Object Type) and the Content Type—you can determine if an item is a file, a folder, or a document set, and increment a specific counter for each.
Log in to Power Automate, go to 'Create', and select either 'Instant cloud flow' (for manual triggers) or 'Scheduled cloud flow' if you want this count to run periodically.
Add three 'Initialize variable' actions at the beginning of your flow. Name them 'FolderCount', 'DocumentSetCount', and 'DocumentCount'. Set their types to 'Integer' and their initial values to 0.
Add the SharePoint 'Get files (properties only)' action. Select your Site Address and Library Name. If your library has many items, go to the action's Settings, turn on Pagination, and set a threshold higher than your total item count.
Add an 'Apply to each' loop using the 'value' dynamic content from the 'Get files' action. Inside the loop, add a 'Condition' or 'Switch' action to check the 'IsFolder' boolean or the 'Content Type' of the current item.
If the item is a standard document, use the 'Increment variable' action to add 1 to 'DocumentCount'. If it is a folder or document set (distinguished by checking if the Content Type ID starts with 0x0120D520), increment the respective 'FolderCount' or 'DocumentSetCount' variable.

Use PnP PowerShell for Advanced Counting
For administrators comfortable with scripting, PnP PowerShell offers a fast and programmatic way to query SharePoint lists and group items by their FileSystemObjectType.
Manage and Edit Your Downloaded Documents with WPS Office
While SharePoint and Power Automate handle your cloud storage and workflow automation, you still need a reliable, high-performance office suite to edit the documents you manage. WPS Office provides a complete, lightweight, and free solution for all your document needs.
- 1. Download and Install: Visit the official WPS Office website to download the free installer and follow the setup wizard.
- 2. Open SharePoint Documents: Sync your SharePoint library via OneDrive or download your files, then open them directly in WPS Office.
- 3. Edit and Save: Edit your documents seamlessly. WPS Office retains exact formatting when saving back to original Microsoft formats.

Frequently Asked Questions
What is FSObjType in SharePoint?
FSObjType (File System Object Type) is an internal property in SharePoint used to distinguish between different structural elements. Typically, a value of 0 represents a file/document, while a value of 1 represents a folder or a document set.
How can I distinguish a document set from a regular folder in Power Automate?
While both folders and document sets may share an FSObjType of 1, you can differentiate them by checking the item's 'Content Type'. Document Sets use a specific Content Type ID that typically begins with '0x0120D520'.
Can I view separate folder and file counts directly in the SharePoint UI?
No, the standard SharePoint Library Settings only display the total 'ItemCount' which includes both files and folders combined. To get separate counts natively, you would have to manually filter views, which is impractical for large, deeply nested libraries.
Does the 'Item Child Count' column help with this issue?
The 'Item Child Count' column only shows the number of immediate child items within a specific folder. It does not provide a comprehensive, library-wide sum of all folders versus documents.




