Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Flow Overwrites Existing Files in Sharepoint

(0) ShareShare
ReportReport
Posted on by 5

I wrote a flow to automatically take attachemnts from certain e-mails and save them to a folder in a Sharepoint document library. Every week it's supposed to upload the same 5 files. It's working fine, problem is Sharepoint is overwriting the existing files instead of just adding the new ones. I assume this is happening because the files have the same name every week. Unfortunately, I don't have a way to change that.

 

Any suggestions on how I can keep this flow running, but have Sharepoint add the new files alongside the existing documents rather than replacing them?

  • apal Profile Picture
    2 on at
    Re: Flow Overwrites Existing Files in Sharepoint

    Please share your flow. As I want to overwrite the existing file each time as it has the same name.

  • Community Power Platform Member Profile Picture
    on at
    Re: Make Same named files get replaced automatically

    Hi Team,

     

    Kindly help me in understanding the procedure to make the same named file get replaced in the SharepPoint folder without cross verification.

     

    Regards,

    Thamizh S

  • tihomir4 Profile Picture
    2 on at
    Re: Flow Overwrites Existing Files in Sharepoint

    @Vinit_Patil , did you find any solution? 

  • Vinit_Patil Profile Picture
    13 on at
    Re: Flow Overwrites Existing Files in Sharepoint

    Hi Scott,

     

    Based on your suggestion, I referred below articles for the requirement(Flow should be like --> if email received with specific "Subject" and has attachment that should be save to SPO lib and definitely it should not replace existing file if any.)

     

    While researching, I tried to follow several blogs but was stuck in filtering as per subject and in condition to check if file exists as demonstrated in this article:- https://powerusers.microsoft.com/t5/Building-Flows/Is-there-an-Exists-for-single-item-from-a-list-access/td-p/89440

     

    Also I am would like to concat the attachment name with current date if the file already exists in SPO Library as suggested below https://techcommunity.microsoft.com/t5/PowerApps-Flow/Concat-quot-Todays-Date-quot-for-File-Name-Save-Attachment-Help/td-p/140425

     

    If possible, can you please help me with steps with clear screenshots of the flow I am looking for so I can try to replicate. I am messing up in either of the steps while implementing.

  • ScottShearer Profile Picture
    25,208 Most Valuable Professional on at
    Re: Flow Overwrites Existing Files in Sharepoint

    @Vinit_Patil:

     

    Here is a suggestion:

    • In your logic, add a SharePoint Get Files action for every attachment
    • Use an ODATA filter and filter on the file name of the attachment
    • If any items are returned by Get Files, you know the file already exists
      • If so, take action as suggested above to rename the attachment when saving to SharePoint

     

    Scott

     

  • Vinit_Patil Profile Picture
    13 on at
    Re: Flow Overwrites Existing Files in Sharepoint

    Hi Scott,

     

    I am using Save my email attachments to a SharePoint document library and under this i have used filter email condition. In this flow, the file gets overwritten if it has same name though I understand there are version created which is helpful. Is there anyway where we can check if the attachment has the same as available in the SharePoint Library and we can change it to current on the go?

     

    Also, are there any rules where I can create exactly above replica in Exchange Online instead of using Flow?

     

    Any suggestions are helpful. Please loop in exchange or SPO community if required.

     

  • bryanw Profile Picture
    5 on at
    Re: Flow Overwrites Existing Files in Sharepoint

    Thanks @ScottShearer, your first suggestion worked! Appending the date to the end added the date/time to the file extension, however appending it to the beginning did exactly what we needed. I may still try your versioning solution as well to keep the directory as clean as possible.

  • Verified answer
    ScottShearer Profile Picture
    25,208 Most Valuable Professional on at
    Re: Flow Overwrites Existing Files in Sharepoint

    @bryanw:

     

    Here are two suggestions:

    1) Simply append the current date to the file name when creating/saving the file to SharePoint

    2) Turn on versioning in the document library (it is enabled by default).  I believe that you'll find that when a new file is added that has the same name as an existing file:

    • the new file is added as a new version
    • the existing file is still there as a previous version

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow