How to Overwrite Files Using Create File Action in Power Automate?

While working on Power Automate, I was required to move a file from OneDrive to the SharePoint library automatically. The flow must run daily at a specific time, retrieve the file from OneDrive, and move it to the SharePoint library.

However, the challenge is that the OneDrive file will be uploaded to the library using the same name. So, I need to overwrite the existing file in SharePoint without creating duplicates. And here, they want the SharePoint library to have one file every time.

In this tutorial, I will show you how to overwrite files using create file action in Power Automate.

Overwrite Files Using Create File Action in Power Automate

Before starting the flow, you must have a file in OneDrive. For this example, I created a files in OneDrive:

How to overwrite files using the create file in Power Automate

Also, we require a SharePoint Online document library, so I created one, and inside the document library, the same PDF is present: [At a specific time, the flow ran and moved the OneDrive file to library]

Checking if SharePoint file exists Overwrite in Power Automate

Let’s see how to create it:

1. Navigate to the Power Automate Home page, click + Create, and select the Scheduled Cloud Flow. Then provide the following information:

  • Starting: Provide on which date you want to run your flow.
  • at: Provide the time you want to run the flow, in my case, at 8:00 AM.
  • Repeat every: We want to run the flow daily.
How to update an existing file in Power Automate

2. I need to select all files in OneDrive, so I used the List file in Folders action from OneDrive for business action, then selected the Source Folder path.

PowerAutomate Overwrite a file

3. Next, I added the ‘Get file content‘ action from OneDrive. After that, select the ID from the dynamic content. This will automatically add Apply to each action.

How to overwrite files using the create file using Power Automate

4. Now, inside the ‘For each‘ action, add the ‘Create file’ action for SharePoint. Then, Provide the below Parameters:

  • File Content: Add the ‘File content’ from the dynamic content.
  • Site Address: Choose the SharePoint site from the dropdown.
  • Folder Path: Select the folder from the Show Picker where you want to store the copied files.
  • File Name: Use the dynamic content value ‘Name’ for the file name.
How to overwrite files using the create file action in power automate

5. Now, again, select the create file action, then select Settings, and under the Netwoling, turn off Allow changing.

Overwrite Files using the Create File Action in Power Automate

6. Finally, add a delete file action for OneDrive to delete the file from OneDrive. Then, select the ID from the dynamic content.

Power Automate Overwrite Files using the Create File Action

Run the Flow to Overwrite Files using the Create File Action

Test-1:

Now, it’s time to save the flow. Click on Test -> Select Manually -> click Test.

Overwrite Files using the Create File Action Power Automate

After the flow runs successfully, go to the SharePoint library, and you will see that the file has successfully overwritten the previous file.

How to Overwrite Files using the Create File Action using Power Automate

As you know now, OneDrive has no files. Check the screenshot below:

Power Automate Overwrite Files using the Create File Action for sharePoint connector

Test – 2:

Again, Click on Test -> Select Manually -> click Test. Now we need to check what happens:

Power Automate Flows to Overwrite Files using the Create File Action

If you check now, there is one file in the SharePoint library, but as you can see from the flow run, no new file was created in the SharePoint library. This is my requirement, and this is how I can overwrite files using the make file action in Power Automate.

Also, you may like some more Power Automate tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…