A finance team I worked with dropped a fresh Daily Report.pdf into a OneDrive folder every morning, and a flow copied it to a SharePoint library where the rest of the company read it. The first morning it worked. The second morning the flow failed, because a file with that name was already in the library. What they actually wanted was simple: one current copy in SharePoint, replaced every day.
SharePoint’s Create file action doesn’t replace an existing file by default. In this tutorial, I’ll show you the method Microsoft documents for overwriting a file, and the quick settings change many people use instead, with its trade-offs.
Quick answer: By default, Create file fails with A file with the name … already exists. To overwrite, check for the file with Get file metadata using path; if it exists, replace its content with Update file, and if it doesn’t, use Create file (set to run only when the check fails). A popular shortcut is to turn off Allow chunking in Create file’s settings, but Microsoft doesn’t document that behavior, and it limits the file size to 100 MB.
The example: copy a daily report from OneDrive to SharePoint
The report starts in a OneDrive folder called Document:

The SharePoint library, ReportStorage, already contains yesterday’s copy with the same name, which is exactly the situation that makes Create file fail:

Step 1: Create a scheduled flow
Create a scheduled cloud flow. Give it a name, set the start date and time, and repeat it every day:

After the flow is created, open the Recurrence trigger and set the Time zone, for example Eastern Time. Without it, the time you entered is treated as UTC, so an 8:30 AM run would happen hours earlier or later than you expect.
Step 2: Get the files from OneDrive
Add the OneDrive for Business action List files in folder and choose the source folder:

This action returns subfolders as well as files. If the folder might contain subfolders, add a Filter array that keeps only items where IsFolder is false, so the next step doesn’t fail on a folder.
Next, add Get file content and set File to the Id from the previous step. Power Automate puts it inside a For each loop, so it runs for each file:

Step 3, method 1: Update the file if it exists, create it if not
This is the method built on documented actions, and the one I use for files that matter. Inside the loop, add three SharePoint actions:
- Get file metadata using path: choose the site and enter the file’s path in the library, for example
/ReportStorage/@{items('For_each')?['Name']}. If the file exists, this returns its details, including its Id; if not, the action fails. - Update file: set File Identifier to the Id from Get file metadata using path, and File Content to the OneDrive file content. This replaces the existing file’s content.
- Create file: the same settings as usual (site, folder, file name and content), but in its Settings tab, under Run after, select only has failed for Get file metadata using path. It runs only when the file wasn’t there.
If the library keeps version history, each update adds a new version, so yesterday’s report is still available from the file’s version history. If the library requires check-out, add Check out file before Update file and Check in file after it.
Step 3, method 2: Turn off Allow chunking in Create file
Many flows use a shorter route. Add Create file inside the loop with the site, the folder, the file Name and the File content from OneDrive:

Then open the action’s Settings tab and, under content transfer, turn off Allow chunking:

With chunking off, Create file replaces a file with the same name instead of failing, which is what the screenshots below show. Two cautions, though: Microsoft doesn’t document this behavior, so it could change, and without chunking the action can only handle files up to 100 MB. For small daily reports it works well; for anything larger or business-critical, use method 1.
Step 4: Delete the file from OneDrive
To finish the move, add the OneDrive action Delete file with the same file Id:

Make sure it only runs after the SharePoint step succeeded. It does by default, because an action runs only when the previous one succeeds, unless you change its Run after settings. That way, a failed upload never deletes the only copy.
With method 1, one extra setting is needed. When the file already exists, Create file is skipped, and by default an action after a skipped step doesn’t run. Open Delete file’s Settings, and under Run after for Create file, select both is successful and is skipped.
Step 5: Test the flow
Save the flow, select Test, choose Manually, and run it:

The library still has exactly one Daily Report.pdf, now with a new modified time:

And the OneDrive folder is empty, because the file was deleted after the upload:

If you run the flow again with nothing in OneDrive, the loop has nothing to process, the actions inside it are skipped, and the library stays as it is:

Other ways to replace files
If the file is already in SharePoint and you’re copying it from one library to another, Copy file and Move file have an If another file is already there setting that can replace the existing file. For developers, the SharePoint REST API can add a file with overwrite=true through Send an HTTP request to SharePoint.
For creating folders to put files in, see how to create a folder in SharePoint using Power Automate.
These guides cover more file automation between OneDrive and SharePoint:
- Create a SharePoint Folder in Power Automate [3 Methods, Including Duplicate-Check]
- How to Upload File in SharePoint Using Power Automate Desktop?
- How to Create an Excel File from SharePoint list Items using Power Automate?
- How to Create an Excel File When an Item is Created in SharePoint List Using Power Automate?
- Stop Creating SharePoint Site Columns Manually – Use Power Automate Flow [6 Column Types Covered]
- Power Automate Read Excel File From SharePoint
Frequently Asked Questions
Why does Create file fail with ‘A file with the name already exists’?
By default, the SharePoint Create file action doesn’t replace an existing file. Update the existing file instead, or turn off Allow chunking in the action’s settings.
How do I overwrite a SharePoint file in Power Automate?
Use Get file metadata using path to find the file, then Update file with its Id to replace the content. Use Create file, set to run only if the check fails, for new files.
What does turning off Allow chunking do?
It sends the file in one piece. Many people use it so Create file replaces files with the same name, but it isn’t documented behavior and it limits the file size to 100 MB.
Does overwriting a file keep the old version?
If versioning is turned on in the library, updating the file adds a new version, so you can restore earlier copies from the version history.

I have worked with Microsoft technologies for more than 18 years, including SharePoint, Microsoft 365 and the Power Platform (Power Apps, Power Automate and Power BI), at companies like HP, TCS and KPIT. I started EnjoySharePoint in 2011 to share the solutions I build in real projects with readers in the United States, Canada, the United Kingdom, Australia, New Zealand and beyond. Microsoft has recognized this work with the Microsoft MVP award 13 times since 2014.