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.
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".
See full below. I'll go into each of the actions.
For this example I've used a Compose that contains the folder name we want to find.
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')}'
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'])
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}']
If I ran the flow, the output from Compose Full Folder Path would be:
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"
}
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.
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.
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).
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.
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
WarrenBelz
146,658
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional