Power Automate Rename File

In this Power automate tutorial, we will discuss the Power automate rename file. And also we will discuss the below points:

  • Power automate rename file with date
  • Power automate rename file in SharePoint
  • Power automate rename file extension
  • Power automate rename file OneDrive

Let us see, how to rename file using Power Automate or Microsoft Flow.

Power Automate rename file with date

Here we will see how to rename a file with the date in Microsoft Flow or Power Automate.

In the SharePoint document library, I have an excel file called Balance.xlsx. Now I want to rename the file to BalanceSheet with the current date appended in it by using Microsoft Flow.

flow rename a file in SharePoint
flow rename a file in SharePoint

Steps to rename a File with date in Microsoft Flow

Let us now step by step create a flow that will rename the file.

Step 1: Create a flow in Power Automate

Now we will create a flow to rename a file with the current date.

  • Login to Power Automate, then click on create and select Instant cloud flow.
flow rename a file in SharePoint
flow rename a file in SharePoint
  • Now Provide the flow name and select the Mnually trigger Flow.
power automate rename excel file
power automate rename excel file

Step 2: Get File Content from the SharePoint

In this step, we will Get file content which file name you want to change in SharePoint.

So, click on the Next Step, then select Get File content- SharePoint action. Then provide the site address and File identifier.

power automate rename file with date
power automate rename file with date

Step 3: Rename a file with the date

To rename a file we will create a file in the SharePoint document library. So for this click on the next step and then select Create a file-SharePoint action.

After that provide the site address and Folder path where you want to save the file. Then provide the file name as the Balance sheet and to add date write the below expression:

formatDateTime(utcNow(),'yyyy-MM-dd')

Then add the extension. Next, add the file content from the dynamic content.

power automate rename file with date
power automate rename file with date

Step 4: Run the Flow

Now click on save and run the flow manually, once flow ran successfully.

How to rename file using Microsoft Flow
How to rename file using Microsoft Flow

After that, we can see the SharePoint document library where we store the file is renamed.

power automate rename file
power automate rename file

In this example, we saw how to rename a file using Power Automate. In this case, particularly, we appended the current date with the file name.

Check out, Power Automate Get Data from Excel on SharePoint

Power automate rename file in SharePoint

Here we will see how to rename a file in SharPoint using Http request.

In the SharePoint Document library, I have an excel file called ‘RenamedDocument’ which we want to rename to Product Review, without losing the version History and audacity on the original file, and this can happen via Http request.

power automate rename excel file
power automate rename excel file

Steps to rename a file in SharePoint using Power Automate

Step 1: Create a Flow in Power Automate

To create a Flow, Login to Power Automate, then click on Create and select instant cloud flow.

how to rename a file in SharPoint using Http request
how to rename a file in SharePoint using Http request

Now provide the Flow name and select the trigger i.e. ‘For a selected File‘- SharePoint.

power automate rename excel file in SharePoint
power automate rename excel file in SharePoint

Step 2: For a selected File in SharePoint

In this step, provide the SharePoint site address and Library name of the file which you want to rename.

power automate rename excel file in SharePoint
power automate rename excel file in SharePoint

Step 3: Get File Properties

In this step, we will get the file properties of the file that we want to rename.

So for this click on the Next step, then select Get File Properties– SharePoint. And then provide the SharePoint site address, library name, and Id of the file.

power automate rename file in SharePoint
power automate rename file in SharePoint

Step 4: Rename the File in SharePoint

To rename the file we will send the Http request to SharePoint.

So click on the Next step, select ‘Send an Http request in SharePoint‘ action.

Then Provide the site address and in the method select the Post from the list. Next, we will provide the Uri, we can get the URI by following the below steps:

  • Copy the site url
  • Then open the new tab in browser and paste the url.
  • Next remove all other part after the site name ‘https://tsinfotechnologies.sharepoint.com/sites/EnjoySharePoint’
  • Now we will add the api like below:
https://tsinfotechnologies.sharepoint.com/sites/EnjoySharePoint/_api/lists/GetByTitle('Documents')/Items(7)

So in this replace the ‘Documents’ with your document library and 7 with your item id number. Then click enter, you will come across XML like below.

power automate rename file
power automate rename file

Next copy the URL from the _api and then paste it in the Uri section, after that change the 7 with the id of the file from dynamic content.

Next in the headers, part add the header and value like below

HeaderValue
content-typeapplication/json;odata:verbose
IF-MATCH*
X-HTTP-METHODPATCH
power automate rename excel file in SharePoint

Then in Body part add the json, in type we can get it from XML which we have in previous steps.

So go to that XML and then select ctrl+F, in the finder box search ‘sp data’ so you will come across below text

power automate rename excel file in SharePoint
power automate rename excel file in SharePoint

At last in FileLeafRef add the name which you want to rename.

Rename file in SharePoint using Microsoft flow
Rename file in SharePoint using Microsoft flow

Once your flow is ready we will test the flow manually.

Step 5: Run the Flow

When you save the flow and you want to run the flow in Microsoft Flow, you will come through this type of warning.

power automate rename file in SharePoint
power automate rename file in SharePoint

To run the flow go to the SharePoint Document Library, where you have stored your file.

Then select the file, click on the More icon -> Power Automate -> you can see your flow name.

power automate rename excel file in SharePoint
power automate rename excel file in SharePoint

Then your flow will run and you can see the file get renamed.

power automate rename excel file in SharePoint
power automate rename excel file in SharePoint

And also you can check the flow in the Microsoft flow:

power automate rename excel file
power automate rename excel file

Also read, Power Automate send an email with an attachment from SharePoint

Power automate rename file extension

Here we will see how to rename the file extension using power automate.

So I have an excel file in the SharePoint library, so we will change the file to pdf using Power automate.

In Power automate, select the manually triggered flow option, and then click on the next step.

power automate rename file extension
power automate rename file extension

Select the Get File content action, provide the site address and file identifier of the file.

flow rename file in SharePoint
flow rename file in SharePoint

Next click on the Next step, then select create a file action. Then provide the site address, folder path, in filename add the extension to pdf and in file content add the content from the dynamic content.

power automate rename file extension
power automate rename file extension

Once the flow is ready, save and run the flow manually. You can see the flow run successfully.

power automate rename files in folder
power automate rename files in folder

After that, we can check the file extension is renamed or not, so for this go to the document library.

power automate rename file extension
power automate rename file extension

Also, read, Power Automate update SharePoint list item

Power automate rename file OneDrive

Here we will see how to rename a file in OneDrive using Power automate.

I have a weekly report which I upload the report in one drive every week. So I want the file gets renamed with the current date. if the date is 2021-06-12, then the file gets renamed to weekly report 2021-06-12.

Steps to rename file in OneDrive using Microsoft Flow

Step 1: Create a Flow in Power automate

To create a flow click on Create and then select Automated cloud flow.

Microsoft flow rename file in OneDrive
Microsoft flow rename file in OneDrive

Next, provide the flow name and select the ‘When a file is created‘-onedrive business. Click on Create.

Microsoft flow rename file in OneDrive
Microsoft flow rename file in OneDrive

Step 2: When a file is created in OneDrive

In this step provide the folder name, where you want to create a file.

Microsoft flow rename file in OneDrive
Microsoft flow rename file in OneDrive

Step 3: Rename a file using Path

To rename a file click on the Next step, and then select the ‘Move or rename a file using path’ action.

Then provide the file path from the dynamic content, then in Destination file path add the path with rename file with current date expression and overwrite choose yes from dropdown.

formatDateTime(utcNow(),'yyyy-mm-dd')
flow rename file in OneDrive
flow rename file in OneDrive

Once your flow is ready click on save and run the flow manually.

Step 4: Run the Flow

To run the flow click on save and upload a file to the OneDrive, once the flow will trigger it will rename the uploaded file.

power automate rename file OneDrive
power automate rename file OneDrive

Once the Flow ran successfully check the OneDrive that the file gets renamed.

power automate rename file OneDrive
power automate rename file OneDrive

You may also like the following Power Automate tutorials:

In this Power Automate tutorial, we discuss the power automate rename file. And also we discuss the below points:

  • Power automate rename file with date
  • Power automate rename file in SharePoint
  • Power automate rename file OneDrive
  • Power automate rename file extension
>