cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bryanw
Level: Power Up

Flow Overwrites Existing Files in Sharepoint

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

6 REPLIES 6
Super User
Super User

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
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

bryanw
Level: Power Up

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.

Vinit_Patil
Level: Power Up

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.

 

Super User
Super User

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

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Vinit_Patil
Level: Power Up

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-ac...

 

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-Sav...

 

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.

tihomir4
Level: Powered On

Re: Flow Overwrites Existing Files in Sharepoint

@Vinit_Patil , did you find any solution? 

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (4,556)