Power Automate Rename File | Power Automate Rename SharePoint File

Power Automate rename file is a common task for every developer. Sometimes, we may give the file name mistakenly or accidentally, and later, we rename the file name with the correct name.

But if you want to rename the file automatically with a single button click, Power Automate can help you achieve this.

In this article, I will tell you about the Power Automate rename file with date, and the Power Automate rename SharePoint file with examples. Also, we will cover:

  • Power Automate Rename Folder using REST API
  • Power Automate change file extension
  • Power Automate rename files in folder

Power Automate Rename File

To work with Power Automate rename SharePoint file, follow the steps below:

To do this, I am using one of my SharePoint document libraries, which has a file named [General Audit Report 2021]. Now, I want to rename this file using Power Automate.

Power Automate rename a file in SharePoint

1. Create a Power Automate Instant cloud flow. Inside the trigger, take a text input as Title.

Power Automate Update SharePoint file name

2. Next, add the Get file content action and configure the required parameters:

  • Site Address: Choose the SharePoint site.
  • File Identifier: Select the file you want to rename.
Power Automate update file name SharePoint

3. Then, select Create file flow action. Set the details like Site address and Folder path.

  • File Name: Provide the Title input from dynamic content.
  • File Content: Provide File content under Get files content.
Power Automate copy and rename file in SharePoint

4. Save and test the flow. In the test flow window, enter the file name’s title. Click Runflow.

Rename a file in SharePoint Power Automate

5. When the flow runs successfully, you can check that the file has been renamed, as shown in the image below:

Power Automate SharePoint copy file and rename

This is how to rename files in SharePoint using Power Automate.

Power Automate Rename File With Date

To rename the SharePoint file with date, follow the below points:

I have created a SharePoint library with a few files and folders, as looked at in the image below:

Power Automate rename SharePoint file

Check out the below steps:

See also  How to convert string to Date using Power Automate?

1. Browse https://make.powerautomate.com/ -> click on +Create and select Instant cloud flow ->Choose Manually trigger a flow and tap on Create button.

Inside the trigger, take a text input.

2. Add a Get file metadata flow action. Add the details like Site Address, Library Name, and ID value.

  • Id: Take the Body/item ID under the Get file metadata column.
Rename file Power Automate

3. In the next step, add the Get file content action and configure the required parameters:

  • Site Address: Choose the SharePoint site or enter the custom value.
  • File Identifier: Select the file you want to rename from the open folder icon.
Power Automate rename file SharePoint

Renaming a file flow action is not available directly in Power Automate. If we want to rename the file name, we would need to create a copy of the file and remove the previous one.

4. Select the Create file action in SharePoint and fill in details like the Site Address and Folder path.

  • File Name: Provide the file name along with the date expression.
@{triggerBody()?['text']}-@{formatDateTime(utcNow(),'dd-MM-yyyy')}.docx
  • File Content: Take the File content Body under Get file content.
Rename file in SharePoint Power Automate

5. After creating the file, delete the old existing file. Select Delete File action.

  • Site Address: Enter the site address from custom value.
  • File Identifier: Select Body/Id from Get file metadata of dynamic content.
@{outputs('Get_file_metadata')?['body/Id']}
Rename SharePoint file Power Automate

Once it is done, save and run the flow manually.

6. The below-represented image shows that the file has been renamed in the SharePoint document library.

Power Automate SharePoint copy file with new name

This is how to copy the file with a new name in the SharePoint document library using Power Automate.

Power Automate Rename Folder using REST API

We can use the Rest API call method in Power Automate to rename the folder name directly without copying and deleting.

I have taken the same SharePoint document library with folders and files, as shown in the screenshot below:

Power Automate rename SharePoint folder

Scenario:

I have a folder named ‘Django Course‘ with item ID 9. I need to rename this SharePoint document library folder to ‘Django Course Module 1’ without changing the version history.

See also  HTML text control in Power Apps

1. Create a Power Automate Instant cloud flow.

2. Here, request the API call to SharePoint to update the folder name. Select and add Send an HTTP request to SharePoint.

Configure the parameters like:

  • Site Address: Select a SharePoint site address from the drop-down.
  • Method: Choose the Post method from the drop-down.
  • Uri: Place the below uri.
_api/web/lists/GetbyTitle('Course Documents')/items(9)/validateUpdateListItem

Replace the URI with the document library name and item ID.

Click Show all to display all the Advanced parameters.

  • Body: Insert the code below.
{
  "formValues": [
    {
      "FieldName": "FileLeafRef",
      "FieldValue": "Django Course Module 1"
    }
  ]
}
Power Automate rename folder on SharePoint

Now, save and run the flow manually.

Output:

You can check the SharePoint document library, where the folder has been renamed with the provided name.

Power Automate update SharePoint folder name

This is how to rename a SharePoint document library folder using Power Automate REST API call to SharePoint.

Power Automate Change File Extension

To change the extension of a SharePoint document library file, check the below steps:

I have the SharePoint document library file in a Word document; we wanted to change the file to an Excel extension.

Power Automate update file name with extension

See the below steps:

1. Create a Manual trigger flow in Power Automate.

2. Then, add the Get file content action and set up the necessary parameters:

  • Site Address: Select the SharePoint site from the options provided or input a custom value.
  • File Identifier: Open the folder icon to choose the specific file from the library.
Power Automate rename SharePoint  file extension

3. Next, click & select Create file action. Provide the below details:

  • Site Address: Choose a SharePoint site.
  • Folder Path: Select the document library.
  • File Name: Provide the file name with the extension xlsx.
  • File Content: Add File content from dynamic content.
Power Automate rename excel file extension

Click on Save and test.

Output:

You can see the flow run successfully. In the SharePoint document library, we can check document library file extension has been updated.

Power Automate copy and rename file extension

Power Automate Rename files in SharePoint Folder [Check In- Check Out actions]

To rename a file in a folder on SharePoint, follow the below-mentioned example.

Here, I have taken another SharePoint library with files inside a folder. You can check the image below:

See also  How to create a sharing link for a file or folder using Power Automate?

I wanted to rename the SharePoint file [Quality Analysis] present inside the folder.

Power Automate rename file in SharePoint

Go through the below points:

1. Take Check out file flow action and give the parameters like Site Address and Library Name.

  • Id: Enter file id value manually.
Power Automate update file name

2. To rename a file inside a folder, call REST API to SharePoint. Add Send an HTTP request to SharePoint flow action.

  • Site Address: Select a SharePoint site address from the drop-down.
  • Method: Choose the Post method from the drop-down.
  • Uri: Place the below uri.

Replace document name and item id.

_api/web/lists/GetbyTitle('Testing Documents')/items(10)/validateUpdateListItem
  • Body: Insert the code provided below.
{
  "formValues": [
    {
      "FieldName": "FileLeafRef",
      "FieldValue": "Quality Assesment Document"
    }
  ]
}
SharePoint rename file Power Automate

3. Again, we need to check in the file. For that, use the Check in file flow action of SharePoint. Give the Site Address and Library name.

  • Id: Enter the same id of a file manually.
  • Comments: Provide the comment manually.
  • Check In Type: Select the check-in type from the drop-down.
Move or rename a file Power Automate

Once it is completed, save and run the flow.

4. When the flow runs successfully, you can observe that the file name inside a folder has been renamed.

Power Automate copy and rename file

This is all about how we can rename files in the SharePoint folder using Power Automate.

Also, you may like:

Conclusion

In this tutorial, I have discussed how to rename file in Power Automate, and how to rename file in SharePoint Power Automate, including:

  • Power Automate rename files in folder
  • Power Automate Rename Folder using REST API
  • Power Automate change file extension
  • How do you “Go to the XML Code”? Do I need to be in the sharepoint library? The home page of the site? Where do I click to display XML code? I am a novice and have no idea how to do this step.

  • I followed your “Power automate rename file in SharePoint using Http Request” guide. Everything went fine, except the “Send an HTTP request to SharePoint” step in the flow runs and runs, and eventually returns a “BadGateway” error. I’ve confirmed that the account authorized within the SharePoint library is the account I’m running the flow with. How do I troubleshoot this?

  • Rename file extension created a new file and it did not replace it.
    Can anyone help with this.
    Is there a way to rename the file extension without creating a new file.
    I also did not get the option: Create file-Rename a file extension, i get create file only.
    In the last step, i was not able to choose body as the identifier as well.

  • >