cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
denisb
Level: Powered On

Saving file with same name to OneDrive - how to avoid overwriting old file?

I'm working on a flow that automates saving Outlook email attachments to OneDrive. Everything works fine except when someone names their file using name that already exists on OneDrive - then old file gets overwritten. How to avoid that?flow1.jpg

flow2.jpg

It would be great if I could get it to add number to the end of the file name as in windows file explorer.

I found solution with adding date and time to file name, but it looks a bit messy.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Saving file with same name to OneDrive - how to avoid overwriting old file?

Hi @denisb . Thank you for your post!

I wrote a blog on this recently.

https://www.alanps1.io/power-platform/flow/flow-excel-formats-only-save-new-email-attachments-to-sha...

 

In the post, I am highlighting using excel files so some of the post won't be relevant, allthough. I have demonstrated a method that involves creating a time stamp and adding that to the end of the file that will avoid overwriting the file and creates a unique file every time. A quote from the post below:

 

"When using "Dynamic content", a common way to get the file name is to use "Attachments name" from the "Get email" action. This is great and very simple, but what if you already have files of the same name in that location?

 

The answer, it will overwrite the old file. This may be what you want and if so great, but what if a system generates a file called "report.csv" every day and sends it to you. You may want to keep a hold of all the reports.csv version that arrive daily.

 

Wouldn't it be better to save reports.csv as reports-2019-03-08-19-15-20.csv so that each new version doesn't conflict with the last?"

 

Hope it helps.

 

If you have found my post helpful, please mark thumbs up.

Any other questions, just ask.

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


2 REPLIES 2
Super User
Super User

Re: Saving file with same name to OneDrive - how to avoid overwriting old file?

Hi @denisb . Thank you for your post!

I wrote a blog on this recently.

https://www.alanps1.io/power-platform/flow/flow-excel-formats-only-save-new-email-attachments-to-sha...

 

In the post, I am highlighting using excel files so some of the post won't be relevant, allthough. I have demonstrated a method that involves creating a time stamp and adding that to the end of the file that will avoid overwriting the file and creates a unique file every time. A quote from the post below:

 

"When using "Dynamic content", a common way to get the file name is to use "Attachments name" from the "Get email" action. This is great and very simple, but what if you already have files of the same name in that location?

 

The answer, it will overwrite the old file. This may be what you want and if so great, but what if a system generates a file called "report.csv" every day and sends it to you. You may want to keep a hold of all the reports.csv version that arrive daily.

 

Wouldn't it be better to save reports.csv as reports-2019-03-08-19-15-20.csv so that each new version doesn't conflict with the last?"

 

Hope it helps.

 

If you have found my post helpful, please mark thumbs up.

Any other questions, just ask.

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


denisb
Level: Powered On

Re: Saving file with same name to OneDrive - how to avoid overwriting old file?

I was trying to avoid adding timestamp, but had some unexpected behavior in Do until loop where I was checking for existance of file with the same name. Most of the time flow was successful, but some times it got stuck in loop.flow3.png

Flow4.png

flow5.png

 

After 3 days of playing with it I gave up and went with timestamp solution, so I'm gonna mark above as solution

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow 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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 212 members 4,242 guests
Please welcome our newest community members: