How to Rename Subfolders in a SharePoint Document Library Using Power Automate?

Last week, while working on a project using Power Automate, I encountered a unique requirement: the need to rename specific folders across multiple directories within a SharePoint document library. Specifically, a subfolder named cp reports needed to be renamed to Corporate Reports. This situation arose in a library containing over 100 parent folders, each subfolder needing to be renamed.

In this tutorial, I will show you how to rename subfolders in a SharePoint document library using Power Automate. Also, we will see how to rename a SharePoint folder using Power Automate.

Rename Subfolders in a SharePoint Folder Using Power Automate

For this example, I created a SharePoint document library called Corporate Projects. This library has various folders, such as Financial Analysis, Marketing Campaigns, etc.

Each folder contains a subfolder called cp reports. Now, I want to rename the subfolder to Corporate Reports, which should affect all the folders inside the library. You can refer to the folder structure below:

Corporate Projects
->Financial Analysis
     ->cp reports
->Marketing Campaigns
     ->cp reports
->Product Development
     ->cp reports
->Project Management
     ->cp reports
->Sales Reports
     ->cp reports
Power Automate Rename a SharePoint Folder

Now follow the below steps:

1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

Rename SharePoint folders using Power Automate

2. Then add an Initialize variable action and provide the variable name, type it as a String, and in value, provide a new subfolder name Corporate Reports, write the below expression:

Rename sub folder in SharePoint Document Set using Power Automate

3. Add the Get files (properties only) action from the SharePoint connector, which retrieves all the files in the document library. Then, select the Site Address and Library Name from the drop-down menu.

Then expand the advanced parameters and provide the filter query below :

substringof('cp reports',FileLeafRef)

You can change it according to the requirements.

How to rename SharePoint sub folder using Power Automate

4. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter: Related Power Automate articles:

  • Site Address: Select the SharePoint site where you want to rename the subfolder name
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('Full Path')/ListItemAllFields
  • Headers: Add a key-value pair:
{
 "Accept" : "application/json;odata=verbose",
 "X-HTTP-Method" : "MERGE",
 "If-Match" : "*"
}
  • Body: Provide the below JSON format:
{
   "Title": "@{variables('varNewFolderName')}",
    "FileLeafRef": "@{variables('varNewFolderName')}"
}
How to Rename Sub Folder in a SharePoint Folder using Power Automate

Now, click Save and run the flow manually. After it runs successfully, go to the SharePoint document library, and you will see that the subfolder name has changed.

How to Rename Sub Folder in a SharePoint Folder in Power Automate

You can rename the subfolder name in the SharePoint document library using Power Automae.

Rename a SharePoint Folder Using Power Automate

Suppose you have a SharePoint library called Certification Documents, where each folder is named after a certification document’s ID and issuance date (e.g., ISO9001 2023). When certifications expire, you want to rename these folders to mark them as Expired.

For example, if a folder name starts with ISO9001 and it’s now expired, Power Automate should rename it to Expired ISO9001 2023.

Rename a SharePoint Folder using Power Automate

Now, I want to rename it as Expired ISO9001 2023. To do this, follow the below steps:

1. Go to Power Automate and create an Instant Cloud flow by using the trigger flow (i.e., manually trigger a flow).

How to rename a SharePoint folder using Power Automate

2. Add the Get files (properties only) action and provide the below parameters:

  • Site Address: The SharePoint site address from the drop-down menu.
  • Library Name: Select the library name where your folder is present.
  • Filter Query: provide the following:
substringof('ISO9001 2023',FileLeafRef)
Rename a SharePoint Folder in Power Automate

3. Lastly, add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site where you want to rename the folder name
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('CertificationDocuments/ISO9001 2023')/ListItemAllFields
  • Headers: Add a key-value pair:
{
  "Accept": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE",
  "If-Match": "*"
}
  • Body: Provide the below JSON format:
{
   "Title": "Expired ISO9001 2023",
    "FileLeafRef": "Expired ISO9001 2023"
}
How to Rename a SharePoint Folder in Power Automate

Now, click Save and run the flow manually. After it runs successfully, go to the SharePoint document library, and you will see that the folder name has changed.

How to Rename a SharePoint document library Folder in Power Automate

Conclusion

In this tutorial, I explained how to use Power Automate to rename folders and subfolders within a SharePoint document library. We covered two examples: renaming specific subfolders within multiple parent folders in a library and renaming folders based on specific criteria, such as marking expired certification folders.

Related Power Automate articles:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…