In this “Power Automate Rename File” tutorial, we will learn how to rename the file(s) in the SharePoint Online document library using Power Automate and two other manual ways.
Sometimes, due to business use cases, we need to rename files in SharePoint Online, but if you have a large number of files, renaming them manually will take a lot of time, so using Power Automate or a PowerShell script is the only way to rename multiple files automatically.
Step-by-Step Instructions for Using Power Automate Rename File to Rename Multiple Files Quickly
Here is the step-by-step guide on how we can rename multiple files quickly:
Rename files in SharePoint using Power Automate
Using the below Power Automate we can rename multiple files in the SharePoint Online document library.

As usual, we will learn the steps in the above flow.
Prerequisites: Rename multiple files in SharePoint (Power Automate Rename File)
You will need the following as part of the prerequisites:
- We should have a document library with a sufficient number of documents to rename.
Variable declaration section: Rename multiple files in SharePoint
Initialize the below variables:
- arrItemsFromSPList – a type of Array
- intLastItemIDfromSPList – a type of integer with the default value of 0.
- boolVarIsArrayEmpty – a type of Boolean with the default value of false.
- strVarFileName – a type of string
- strVarFileID – a type of string

Do Until Loop Power Automate: Auto increment number to rename multiple files in SharePoint
Below is the Do Until loop section.

Explanation of Do Until Loop Power Automate
Step 1: Set loop termination condition
@variables('boolVarIsArrayEmpty')
Note:
- In the change limit, the count is equal to 5000
Compose data operation action to check the item count from the get files query result
Step 2: Get files (properties only)
Add a “Get files (properties only)” action and pass the below parameters:
- Site Address: Your site URL
- Library Name: Select your library name (Title)
- Include Nested Items: Select “No”, as we are not querying the nested documents from the document library.
- Filter Query: ID gt @{variables(‘intLastItemIDfromSPList’)}
- Top Count: 5000
Get files (properties only) configuration in Power Automate
Step 4: Select data operation to Get Files Properties Only mapping
Add a select data operation action to filter out the unwanted columns from the get files query result, with the intention to keep only the needed columns for further actions in the flow.
In the “From” pass the below:
@{outputs('Get_files_(properties_only)')?['body/value']}
Select data operation to Get Files Properties Only mapping
And, for the mapping, add only the columns you need; leaving the rest will cut the flow execution time in half (double your flow execution speed).
Step 5: Add a compose data operation for the union function.
@{union(variables('arrItemsFromSPList'),body('Select_Get_Files_Properties_Only_mapping'))}

Step 5: Add a set variable action to assign the data to array collection.
@{outputs('Compose')}
Add a set variable action to assign the data to the array collection
Step 6: Add an apply to control to rename the files in SharePoint

Basically, in the above steps, we are getting the file name and file ID, then using the Concat() function to combine them.
@{concat(variables('strVarFileName'),'_',variables('strVarFileID'))}

Note:
- For this demo, we are just adding the file ID to the existing file name; however, for your use case, you may construct a different file name.
Then, finally, check whether the list item is a folder or document; if it is a document, we should rename the file; otherwise, not.

In the folder condition no section, add a send an HTTP request to SharePoint action and pass the below parameters:
- Site Address: Your site URL
- Method: POST
- URI: _api/web/lists/GetByTitle(‘Your document library Title’)/items(‘select item id ‘)/ValidateUpdateListItem
- Body: In the body pass the below:
{ "formValues":[ { "FieldName": "FileLeafRef", "FieldValue": "@{outputs('Compose_-_File_Name_with_ID')}" } ] }
Notes:
- In the above body, you just need to pass the value for the “FieldValue” parameter; the rest is left as it is. In this “FieldValue,” we are only passing the new name for the file.
- If you want to rename a single file, you need to call the below API from outside the “apply to each” loop.
_api/web/lists/GetByTitle('Your document library Title')/items('select item id ')/ValidateUpdateListItem
Step 7: Finally, add a condition control to terminate the Do Until loop

Things to perform here:
Add the following to the condition to see if the get file properties query result is empty.
empty(outputs('Get_files_(properties_only)')?['body']?['value'])
If the get file properties query result output is empty, set the variable “boolVarIsArrayEmpty” to true; otherwise, set the variable “intLastItemIDfromSPList” like below:
@{last(outputs('Get_files_(properties_only)')?['body']?['value']).ID}
Power Automate to rename files in SharePoint – Demo (flow execution)
Now let’s run the flow manually.

Rename multiple files in SharePoint using Power Automate – Demo (Verify the document library)
Now, let’s go to the SharePoint document library. We can see that all files have been appended (renamed) with their ID.

By now, we have learned how to rename files in the SharePoint Online document library using Power Automate; now, let’s learn how to rename a file in SharePoint Online manually.
Rename file in SharePoint Online manually
In SharePoint Online, we can rename a file in two ways.
Approach 1: Rename the file in SharePoint Online using the ECB menu
Select a file, click on the three dots, then click on the Rename link.

Approach 2: Open the details pane in SharePoint online
Select a file, click on the details pane, then in the “Name” column, enter the new file name.

Summary: Rename files in SharePoint Online using Power Automate
Thus, in this article, we have learned the following with respect to renaming the files in the SharePoint Online document library:
- How to rename multiple files in SharePoint using Power Automate.
- How to rename a file in SharePoint Online using the ECB menu.
- How to rename a file in SharePoint Online using the property details pane.
- How to use Do Until and Apply to Each loop control to rename files in SharePoint.
- How to use “ValidateUpdateListItem” SharePoint REST API in Power Automate.
See Also: Power Automate Tutorials