How to Get SharePoint Document Library Folder Path in Power Automate?

I currently work for a client who requires me to retrieve the SharePoint document library‘s folder path only if it satisfies the given condition. After researching, I found out how to achieve this.

Let me explain how to get SharePoint document library folder path in Power Automate.

Get SharePoint Library Folder Path in Power Automate

Here, I have a SharePoint list. Which has the Due Date and Initial Email as the date and time fields. If the initial email column has the current date, then for that record, I need to subtract one month from the due date. Later, format it as ‘MMM-yy,’ for example, “Aug-24.”

how to get url of sharepoint folder

Now, I need to check if that formatted date is present for any folder names in the SharePoint document library below. If this condition is satisfied, I must send that folder link in the email for the employee to report.

how to get folder path in powerautomate

Look at the output of the above scenario in the example below.

power automate get folder path

Follow the steps below to achieve this.

1. Create one Schedule flow in Power Automate. This flow must run daily, so provide the values for parameters like the one below in the recurrence trigger.

  • Interval: 1
  • Frequency: Day

Then, add the Get items action and provide the parameters.

  • Site Address: Provide site URL.
  • List Name: Provide SharePoint list name.
  • Filter Query: Use this formula if you use New designer mode in PowerAutomate. InitialEmail eq formatDateTime(utcNow(), ‘MM-dd-yyyy’)
  • Add this formatDateTime(utcNow(), ‘MM-dd-yyyy’) using expression.
how to get path of sharepoint folder

2. To get SharePoint document library files and folders, add the Get files(properties only) action and provide the site address and library name.

how to get folder path of sharepoint in powerautomate

3. Now, add three Initialize variables for the following requirement.

  • Initialize variable 1: Provide only the SharePoint site URL.
  • Initialize variable 2: Provide the SharePoint document library’s internal name.
  • Initialize variable 3: This is for the folder path; keep its value empty.
power automate link to sharepoint folder

4. Then, add one Condition; by default, it will take the Apply to each loop. In the condition action, provide the following conditions.

  • IsFolder eq true / IsFolder is equal to true. [Take IsFolder from the dynamic of the Get file(properties only) action and true from the expression.]
  • Name contains string(….). [Take Name from Get file(properties only) action].
string(subtractFromTime(items('Apply_to_each_2')?['DueDate'],1,'Month','MMM-yy'))

In place of items(‘Apply_to_each_2’)?[‘DueDate’] provide the Duedate column dynamically. This formula will subtract one month and format the date in ‘MMM-yy.’

get folders in document library power automate

5. In the If yes branch of Condition. Add Set variable and Compose actions. Then, provide the values for those actions as shown below.

  • Set variable action:
    • Name: Take the Initialize variable 3 name here.
    • Value: Take the Name dynamically from the Get file(properties only) action.
  • Compose action: Provide the below formula.
concat(variables('SiteURL'),'/',variables('Library Address'),'/',variables('Folder Path'))

Here, variables(‘SiteURL’), variables(‘Library Address’), and variables(‘Folder Path’) are the outputs of the variables we took above. All three variables concatenate with ‘/.’

sharepoint get list of folders in document library power automate

6. Add the Send an email(V2) action below the Compose action. Then, add the output of compose in the anchor tag <a>.

<p> Hello, Patti<br>
Check out this <a href="@{outputs('Compose')}">Report</a> Once

ThankYou.
</p>
full path power automate

7. Now, save the flow and test it. If the initial email date column has a current date. Then, it will subtract one month from the Due date column and check whether this formatted date is present with the folder names in the SharePoint document library.

It will email that folder path to a particular person if it is present.

I hope you found this helpful article. You can use it as a reference when required to get the SharePoint document library folder path based on a condition in Power Automate.

Also, you may like:

>