How get only Files (and exclude Folders) from a SharePoint Document Library using Power Automate

The Get files SharePoint actions for flows in Power Automate lets you get items from a document library. And by items we mean both files and folders. But most of the time we just want to work with files, so we need the Get files actions to return a collection of files only and to exclude any folders.

Fortunately, there is a property we can check to see whether the item is a folder: isFolder

IsFolder property. This will be True when the item is a folder, false otherwise.

The actual name of this property is “{IsFolder}” but the Get files SharePoint actions doesn’t allow us to use this name in Filter queries. However, we can use an alternative property name for “{IsFolder}” called FSObjType and this works with Filter queries.

Using the FSObjType property

The following Filter query will return only files from the Get Files action. Folders will not be included in the search results. It uses the File System Object type property (FSObjType):

Get Files action using the File System Object type property (FSObjType):
FSObjType eq 0    will return Files only
FSObjType eq 1    will return Folders only

For other types see: FileSystemObjectType enumeration.

Using the isFolder property within a Flow

In the example below the isFolder property is used inside a Condition. This method does have its uses, but it is much slower than using FSObjType in a query filter. This is because the Get Files action below returned an unfiltered collection of items, so we now need to check each item to determine whether the item is a file or a folder:

No query fillter in the Get Files action.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: