Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

Rename a file in SharePoint with a single Power Automate action

Posted on April 7, 2021February 10, 2022 by Tom

“Why can’t Power Automate rename a file in SharePoint in the same way it can rename a file in OneDrive? It’s one of the most basic operations!”


Power Automate is still missing an action that will allow you to rename a file in SharePoint. You can update all the file properties with the ‘Update file properties’ action, but file name is not one of them.

One solution I’ve seen is to ‘Copy file’ with a new name, and then delete the original one. It’ll achieve the goal, but it’ll create a new file with new ID, new link, and empty version history. I don’t think it’s a good solution.

Another, much better solution is to update the file name with an HTTP request. As already mentioned a few times on this blog, HTTP requests give you much more control. The limitations of the standard Power Automate actions don’t apply to HTTP requests, the only limitation for them is what the SharePoint REST API allows you to do. And it allows you to update the file name.

But even here I’ve seen complicated HTTP requests that I think are quite complex for most users.

The HTTP request doesn’t have to be as complicated, you don’t need a SharePoint consultant to create it for you.

Simple HTTP request

You can use the same HTTP request as when updating a single SharePoint column. If you define the update operation in the ‘Uri’, you don’t need all the headers. And if you use the right operation, you don’t even need such complicated ‘Body’. The request below is all you need to rename a file.

Method: POST

Uri: _api/web/lists/GetByTitle('<LibraryName>')/items(<DocumentID>)/validateUpdateListItem

Body:
{
    "formValues":[
	{
	    "FieldName": "FileLeafRef",
	    "FieldValue": "<NewFileNameWithExtension>"
	}
    ]
}

Why is the “FieldName”: “FileLeafRef” and not “Name”? As already explain in the article on searching files by their name, FileLeafRef represents the file name. It’s an internal column name that’s used in SharePoint for ages, even though it’s not visible anywhere in the properties. Just don’t forget to include also the file extension in the file name.

Power Automate rename file in SharePoint

Summary

Changing file name is a basic operation for every document storage, and it’s strange that Power Automate doesn’t have an action to rename files stored in SharePoint. But as already shown multiple times, there’s a workaround. And the workaround doesn’t have to be complicated, it can be a simple HTTP request. Simple, if you know the ‘Uri’, ‘Body’ and the internal name for the ‘Name’ property…

You can even update the file name without creating a new version of the document with a small addition to the request. But it might get a bit more complicated if you want to update content of an existing file, not just the file name.


πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

17 thoughts on “Rename a file in SharePoint with a single Power Automate action”

  1. Paul says:
    May 20, 2021 at 10:52 am

    Hi Tom,

    Thanks for your great site.

    Have you ever tried to “send a HTTP request” to update a multi-choice people picker with an individual or even better an O365 group?

    JSON I am trying in a POST:
    {

    “formValues” :
    [
    {
    “FieldName”:”Assigned_x0020_to”,
    “FieldValue”:”O365groupID”
    }
    ],
    “bNewDocumentUpdate”:false
    }

    Kind Regards,
    Paul

    Reply
    1. Tom says:
      May 22, 2021 at 8:44 pm

      Hello Paul,
      Person or Group column needs a specific format for the “FieldValue”: “[{‘Key’:’claimsLogin’}]”. It works for both, users and M365 groups, e.g. to update 1 M365 group and 1 user to item.
      "FieldValue": "[{'Key':'c:0o.c|federateddirectoryclaimprovider|691a0c9d-xxxx-44e8-yyyy-d6df6cd591e8'},{'Key':'i:0#.f|membership|xxx@tomriha.com'}]"

      Reply
  2. Gary says:
    June 24, 2021 at 11:17 pm

    Excellent tutorial. I was struggling with thsi and your approach is simple and straightforward. The vast majority of sites use the create new file with new file name and delete old file process. This makes more sense.

    Reply
  3. Matt Harris says:
    July 15, 2021 at 1:00 pm

    This has got me so close to what I want. Thanks. Trouble isI want to use it to rename item in doc set without changing name of document set. Any ideas?

    Reply
    1. Tom says:
      July 19, 2021 at 2:08 pm

      Hello Matt,
      it’s been a long time since I worked with Document Sets so I’m afraid that I don’t know how to do this.

      Reply
  4. Pingback: How to Work Effectively With SharePoint Documents using Power Automate – Implementing Tae of <T>
  5. Craig says:
    November 26, 2021 at 7:26 am

    Hi Tom,

    Great article, keep up the good work!

    Reply
  6. Monroe Horn says:
    November 27, 2021 at 9:59 pm

    Thanks for this information. However, when I try this solution I keep getting an error that says the following:
    Value cannot be null.
    Parameter name: formValues

    Here is the body of my request:
    {
    “formValues”:[
    {
    “FieldName”: “FileLeafRef”,
    “FieldValue”: “test.pdf”
    }
    ]
    }

    Do you know why this wouldn’t work?

    Thank you very much

    Reply
  7. Monroe Horn says:
    November 27, 2021 at 10:21 pm

    Hello again,

    I got it to work. I had the wrong HTTP request type.

    Reply
  8. Humberto says:
    June 16, 2022 at 5:41 am

    Excellent post. My input, after a couple of hours struggling with default Documents Library, in spanish (can’t confirm that was the issue), would be to target to the guid enpoint as:

    _api/Lists(guid’81c636c1-7a88-4c47-b72d-a29cc6abc595′)/Items(#id#)/validateUpdateListItem,

    already tested and worked like a charm.

    To find out the guid:
    * open the _api/Lists endpoint
    * search an online xml viewer and search for the library name

    Reply
    1. Tom says:
      June 22, 2022 at 8:53 pm

      Hello Humberto,
      thank you for sharing your solution. It can be a problem if you use multiple languages on a SharePoint site and rename a list/library as it’ll rename it only for the specific language, but list guid is always unique no matter what.
      I wrote about it a bit here: https://tomriha.com/use-the-correct-sharepoint-list-name-in-the-power-automate-http-request/

      Reply
  9. Paul says:
    June 24, 2022 at 8:54 am

    Thanks Tom, your solution worked so well!

    Reply
  10. abc says:
    August 30, 2022 at 4:40 am

    Good

    Reply
  11. Rod says:
    February 24, 2023 at 1:45 am

    Hi Tom

    I’ve written the flow for this, but it keeps timing out and failing. Any ideas why this would be happening?

    Reply
    1. Tom says:
      March 1, 2023 at 11:06 pm

      Hello Rod,
      I’d double check if the action is correctly configured, and if it is, maybe the output will tell you more on what’s going on.

      Reply
  12. Alex C says:
    October 18, 2023 at 12:30 pm

    Hello Tom,
    I’ve tried your solution to change the file extension from .docx to .pdf. I included the file name from the Dynamic content and added ‘.pdf’ at the end. The script worked fine and didn’t gave me any errors.
    However the file extension never changed to PDF.
    Is there any possibility to change the file extension without loosing the ID of the document in library?
    Thank you.

    Reply
    1. Tom says:
      November 19, 2023 at 1:44 pm

      Hello Alex,
      I think it’s possible, but maybe you need to change also the file type (File_x0020_Type) with the request? I never tried it though.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Working on an Approval process?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy a fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes