web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Issue with Flow to cop...
Power Automate
Answered

Issue with Flow to copy/create file from SharePoint A to SharePoint B

(2) ShareShare
ReportReport
Posted on by 79
Hi there,
 
I have numerous flows currently set up that will take an attachment from an email and upload that attachment to a SharePoint folder. This SharePoint folder houses ~20 different data reports that are tied via Power Query to reports and thus rely on the file being the same name. These email triggered flows work just fine with no issues.
 
Some of our data reports are too large to send via email and are uploaded to a folder in SharePoint A, however the name of the file typically includes the date. The oversize data reports are uploaded on a daily basis, and I'm trying to set up a flow that will grab the newly uploaded file, rename it so it fits in the Power Query scheme, and then upload/create/copy it into SharePoint B.
 
My issue is that when this flow triggers, it fails because of the following error code (some PII related text changed):
 
"A file with the name Shared Documents/DATA REPORT.xlsx already exists. It was last modified by i:0#.f|membership|REDACTED on 09 Jul 2025 12:15:30 -0700. clientRequestId: e3d55d5e-febe-44ac-8e3b-bb8957516e51 serviceRequestId: a2f3b3a1-8022-9000-69b1-5e3088ba1e1c"
 
In short, because a file already exists in SharePoint B with the same name the flow fails and the file does not automatically get replaced with the new one. Having the same name is imperative to the Power Query structure I've set up for various reports, and I'm confused because this issue is not present with my email triggered flows.
 
Screenshot of the current flow is attached, with some redaction for privacy. For the initialize variable step, which has the purpose of renaming the file, if I do not include the .xlsx suffix, then the file does successfully copy but the content of the file is lost and it won't open.
 
Appreciate any insight to solving this issue. Thank you!
Screenshot 2025-07-21 090318.png
Categories:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Have you looked at using Update File instead
     
    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.
    Thank you!
    Sincerely, Michael Gernaey
  • Suggested answer
    Tomac Profile Picture
    4,055 Moderator on at
    Here's a simple method for checking if the file exists, and if so deleting it before creating the file. The Delay action allows SharePoint to settle the deletion before creating the new file (I set mine to 2 minutes, but the recommended time is 10 minutes)
     
    In the Get Files action you need to choose the Folder the file is in, and use an ODATA query to look for the filename, something like this but customized for your environment:
    name eq '2025-07-21_Excel'
     
    If this comment resolved your issue, please mark it as the answer to help future users who are having this issue
     
     
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Deleting it will not keep the link he has to reporting (if its been attached to Power BI, or any other engine as the File locator will change).
     
    Logically he needs to check if the file exists and update and if not create.
  • Tomac Profile Picture
    4,055 Moderator on at
    @Michael E. Gernaey Ah, I missed that. Great catch.
     
    @DS-21071255-0 as Michael said, you'll want to use the Update File action.
  • FlowingBuckle Profile Picture
    79 on at
     
    I don't think deleting the file will break it as I'm only using Power Query within an Excel workbook and no BI. As long as the file name is an exact match, it shouldn't break the Applied Step of filtering for the specific data report name.
     
    That being said, I haven't had a chance to try out either of the suggestions, but I appreciate the input and will give it a shot tomorrow morning. Both options make sense to me and I think both could be successful, so hopefully I can report back tomorrow with some good news.
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
    If you have a Power Query (where is it at in the same file???) if its in the same file then it won't matter, but you didn't specify. 
     
    If its outside, then you need it to point to the current instance as the DataSource (if for instance that is what you set) the datasource won't necessarily see the same file name or not.
     
    But I don't know what you have fully based on the description so either or :-) would work then.
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,
     

    Solution 1: Delete Before Copy (Recommended)

    Add a step before your copy action to delete the existing file if it exists:


    1. Add "Get file metadata" action (before your copy step)

      • Site Address: Your SharePoint B site

      • File Identifier: Shared Documents/DATA REPORT.xlsx

      • Configure this step to continue on failure


      •  

    2. Add "Delete file" action (conditional)

      • Site Address: Your SharePoint B site

      • File Identifier: Use the File Identifier from the previous step

      • Only run this if the "Get file metadata" step succeeds

      •  

    3. Keep your existing "Copy file" action as is

    Solution 2: Use "Create file" with Overwrite

    Replace your current copy action with:


    1. "Get file content" action

      • Get the content from your source file in SharePoint A


      •  

    2. "Create file" action

      • Site Address: Your SharePoint B site

      • Folder Path: /Shared Documents

      • File Name: DATA REPORT.xlsx

      • File Content: Output from "Get file content"

      • Important: Look for an "Overwrite" setting and set it to Yes/True

      •  


    3.  

    Solution 3: Update File Properties Method


    1. Add "Get files (properties only)" action

      • Site Address: SharePoint B

      • Library: Documents

      • Filter Query: Title eq 'DATA REPORT'


      •  

    2. Add a Condition to check if file exists

      • If file exists: Use "Update file" action

      • If file doesn't exist: Use "Copy file" action 

      •  
     

    Solution 4: Try Different Copy Settings

    In your existing "Copy file" action, look for these settings:


    • Overwrite Flag: Set to True

    • If file exists: Set to Replace

    • Conflict Behavior: Set to Replace
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
  • FlowingBuckle Profile Picture
    79 on at
    Happy to report that the flow successfully worked based on Update File. Had to bring in my organizations AI tool for a little hand holding, but by factoring in a get file metadata step and hard coding the file link as opposed to using an ID or Identifier, I was able to get the data report to successfully update.
     
    Solution goes to Michael, but I'm sure I could've found my way to a solution through Tomac's suggestion as well. Appreciate both of your advice.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 889

#2
Valantis Profile Picture

Valantis 830

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard