Loading...

How to rename files in SharePoint with Power Automate

How to rename files in SharePoint with Power Automate

the issue

Although SharePoint and Power Automate are heavily interwoven, there is no “rename file” action in Power Automate - if the file lives in a SharePoint library. Out of the box that is only possible for files living in OneDrive.

I recently saw a cry for help on twitter and decided to share here how my solution looks like.

In order to change a filename, we will need to use SharePoint REST API, which is accessible to us in Power Automate via the Send an HTTP request to SharePoint action.

the Power Automate flow

Power Automate flow to rename a file

  1. To make things easy, we start with a For selected file trigger. (In a real-world scenario, you’d typically rename a file after something else has happened.)

  2. We then Get file properties (not needed as we already have the ID from the For selected file trigger, but if you run this after another action you will need the file properties to get the ID so that you can rename the right file).

  3. We now need to use the Send an HTTP request to SharePoint action:

    • Site Adress: choose from Dropdown
    • Method: Get
    • Uri: _api/lists/getbytitle('<DisplayName of your Library goes here>')

    This will re turn the ListItemEntityTypeFullName property, which we will need for the next step.

  4. As a last step, use another Send an HTTP request to SharePoint action:

    • Site Adress: choose from Dropdown
    • Method: Post
    • Uri: _api/lists/GetByTitle('<DisplayName of your Library goes here>')/Items(@{outputs('Get_file_properties')?['body/ID']})
    • Headers:
      • Content-type: application/json
      • IF-MATCH: *
      • X-HTTP-METHOD: PATCH
    • Body:
{'__metadata':
{'type':'@{outputs('Send_an_HTTP_request_to_SharePoint_to_get_type')?['body']?['d']?['ListItemEntityTypeFullName']}'},
'FileLeafRef':'<your new filename goes here>'}

For the type, we are selecting the ListItemEntityTypeFullName property from the output of the previous action. You could also use Parse JSON action to obtain that value.

Conclusion

Once again, the Send an HTTP request to SharePoint action in Power Automate is a lifesaver for everything that doesn’t work with the built-in actions. Also, no additional license than your Microsoft 365 license is required to use it.

Resources

To learn more about SharePoint REST, use these resources:

Feedback & what’s next?

I’d love to know what are your renaming-scenarios and also what you use the Send an HTTP request to SharePoint action for! Let me know on twitter. If you found this blog post useful, please also subscribe to my newsletter - news coming about every 2 months, I promise to not spam you!

Published on:

Learn more
Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

From Business Central to SharePoint: The Right Way to Save PDF Files in Power Automate

If you’re pulling PDF files from Microsoft Dynamics 365 Business Central and saving them to SharePoint using Power Automate, there’s one criti...

1 day ago

How to Build Environment-Aware Flows by Fetching CRM Metadata Dynamically in Power Automate

Stop relying on OData workarounds and use a professional API-based pattern instead. When building flows in Power Automate, you often need envi...

2 days ago

Action ‘Update_a_record’ failed: An error has occurred. No resources were found when selecting for update – Fixing Cross-Company Update Issues in Finance & Operations Using Dataverse Virtual Entities (Power Automate)

Recently, while trying to update the Projects table in Finance & Operations using the Fin & Ops Apps actions in Power Automate, we ran...

3 days ago

Power Automate Forward A Meeting Invite In Outlook

A Power Automate flow can forward a meeting invite to a new attendee in Outlook. ... The post Power Automate Forward A Meeting Invite In Outlo...

4 days ago

Power Automate Generative Actions

Power Automate Generative Actions Build Intelligent Automations with Natural Language and AI 📅 Released: Preview (2024-2025) 🎯 Status: Publi...

8 days ago

Create Excel File in OneDrive Using Power Automate and Insert Records Dynamically from Dataverse

Exporting Dataverse records into Excel is a common requirement in Dynamics 365 and Power Platform projects—whether for reporting, backup, or d...

9 days ago

Fixing the “Only 1 of 2 keys provided for lookup, provide keys for dataAreaId, ProjectID / Not found” Error in Power Automate (Fin & Ops Apps)

Recently, while working with the Projects table from a Finance & Operations (F&O) environment, we ran into an error while using the Ge...

10 days ago

Rules of Engagement: How Plugins, Workflows, and Power Automate Coexist in the Execution Pipeline

Understanding how the three automation engines interact—Plugins, Classic Workflows, and Power Automate—is essential for designing predictable,...

11 days ago

Power Automate: Fixing the ‘ChildFlowNeverPublished’ Error

While trying to enable one of the cloud flows from a managed solution I had installed, I encountered the following error:  “{“erro...

14 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy