web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Using power automate t...
Power Automate
Answered

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

(1) ShareShare
ReportReport
Posted on 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. 

 

Categories:
I have the same question (0)
  • Nicktrom55 Profile Picture
    65 on at

    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 

  • Verified answer
    trice602 Profile Picture
    15,402 Super User 2025 Season 2 on at

    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.

     

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    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"
    }

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard