Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Qd8ED4czWC13fziAA0WD8D
Power Automate - Building Flows
Answered

Using power automate to find a folder in sharepoint and return the folder path

Like (1) ShareShare
ReportReport
Posted on 4 Nov 2023 11:52:49 by 65

Hi, 

 

Im trying to see if power automate has the ability to find a folder name in a library, if it exist and return the folder path so that i can use it in a flow for saving documents. 

 

Example: 

Dynamic Content from flow would say: ABC Corp

 

Library:

ABC Corp

1234 Corp

XYZ Corp 

 

Result from Power Automate would be: ABC Corp folder path since it exist. 

 

  • grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on 05 Nov 2023 at 02:14:01
    Re: Using power automate to find a folder in sharepoint and return the folder path

    Get files (properties only) returns files and folders, and allows you to add a Filter query, so this is what I'd use to find the folder based on a name.

     

    For this example, I've got the following folder structure and will try to find the folder with the name "XYZ Corp".

    grantjenkins_0-1699149297651.png

     

    See full below. I'll go into each of the actions.

    grantjenkins_1-1699149342693.png

     

    For this example I've used a Compose that contains the folder name we want to find.

    grantjenkins_7-1699150248698.png

     

    Get files (properties only) returns all folders where the folder name is equal to the folder name we are looking for.

    //FSObjType eq 1 means only return folders (not files)
    //FileLeafRef refers to the folder name
    
    FSObjType eq 1 and FileLeafRef eq '@{outputs('Compose')}'

    grantjenkins_3-1699149579056.png

     

    Condition checks to see if a single folder was found by checking the length of items returned.

    length(outputs('Get_files_(properties_only)')?['body/value'])

    grantjenkins_4-1699149675872.png

     

    If only one folder found, then we go into the Yes branch and retrieve the properties we want. In this example, I've just used another Compose to retrieve the Full Path.

    //Gets the first item returned and retreives the value for FullPath
    
    first(outputs('Get_files_(properties_only)')?['body/value'])?['{FullPath}']

    grantjenkins_5-1699149941696.png

     

    If I ran the flow, the output from Compose Full Folder Path would be:

    grantjenkins_8-1699150296151.png

     

    If you wanted a different property value, then you could chose from any of the ones below that suit your requirement. This is just a sample set of properties/data returned from my flow.

    {
     "ItemInternalId": "120",
     "ID": 120,
     "Modified": "2023-11-05T00:51:37Z",
     "Created": "2023-11-05T00:51:37Z",
     "{Identifier}": "Shared%2bDocuments%252fFolder%2bA%252fFolder%2bB%252fXYZ%2bCorp",
     "{Link}": "https://xtrdev.sharepoint.com/sites/PowerAutomateExamplesV1/Shared%20Documents/Folder%20A/Folder%20B/XYZ%20Corp",
     "{Name}": "XYZ Corp",
     "{FilenameWithExtension}": "XYZ Corp",
     "{Path}": "Shared Documents/Folder A/Folder B/",
     "{FullPath}": "Shared Documents/Folder A/Folder B/XYZ Corp",
     "{IsCheckedOut}": false,
     "{VersionNumber}": "1.0"
    }
  • Verified answer
    trice602 Profile Picture
    13,760 Super User 2025 Season 1 on 04 Nov 2023 at 14:51:44
    Re: Using power automate to find a folder in sharepoint and return the folder path

    Hi @Nicktrom55 ,

     

    Please review this flow and make it your own.  Here I added the subfolder ABC Corp in a test folder and I want to check it if exists and if true, add the folder path to a compose (although not required but shown for test) to use downstream.

     

    trice602_0-1699109181993.png

     

     

     

    So I have a trigger and list folder and pointing to the folder or subfolder I want to check.  Next, I add a conditional action that says if the name of the file or folder is true, do something, else do something.

     

    trice602_1-1699109277285.png

     

     

    On the True side, I am putting the path of the found folder in a compose (again, you don't have to but shown for test here).

     

    trice602_2-1699109378067.png

     

     

    So in this example, I have 13 files and folders in this subfolder.  As it loops through the data it checks if ABC Corp exists and if true, I have the folder path and works well.

     

     

  • Nicktrom55 Profile Picture
    65 on 04 Nov 2023 at 12:26:47
    Re: Using power automate to find a folder in sharepoint and return the folder path

    If there isn’t a way to do that. Would it be possible to get all the folders I have path ID’s and then created an excel file that store the company name and folder ID. And pull that data with the excel get row info power automate. Use that data and paste it as dynamic content into power automate sharepoint add documents to folder. 

    just an idea might 

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started