Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online

Hi Friends,

Today blog is about renaming the folder in the document library using the MS FLOW or MS Power Automate. When I started working on this it seems to be an easy job, but if you look into the connectors you'll find it really difficult as there is no straight forwards connector to do the job.

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online

Issues encountered

  • If you try using the "Get Folder Metadata" connector, you'll not be able to get the ID of the folder as it is returning as the negative value.
  • If you get the ID somehow and try to update the folder name using the "Update File Properties" connector, you'll end up renaming only the title of the folder, but it will still have the old name as the display name which in case is again a failure.
  • There is no other connector which can be utilized to achieve the task of renaming the folder in a document library directly.

Solution

The solution is a simple three-step (at least in this example).

Step 1: Initialize variables

In case you are computing values for the old name and new name, get them into the variables. In this case, I have added them to the variables

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online

Step 2: Use of "Send an HTTP Request to SharePoint" connector

This is the only way to rename the folder. Add the following configuration:

Site Address: <Address to your site>
Method: "POST"
Uri: "_api/web/GetFolderByServerRelativeUrl('Shared Documents/FolderName')/ListItemAllFields"
Headers
  • If-Match: *
  • X-HTTP-Method: MERGE
  • Accept: Application/json;odata-verbose
Body: {
              "Title": "NEW FOLDER NAME",
              "FileLeafRef": "NEW FOLDER NAME"
            }

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online


Step 3: Test Your Flow

Now test your flow, and you'll see that the folder name is now renamed to the new name.

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online


Hope this article would have helped you

Happy Coding..!!
#PowerAutomate #Microsoft #SharePointWidgets

Comments

Popular posts from this blog

SharePoint Framework (SPFx) : Cascade dropdown in webpart properties

SharePoint Image Gallery

Checking user permission in SharePoint Framework (SPFx) webpart