cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous . 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-sharepoint/

 

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!


View solution in original post

2 REPLIES 2
AlanPs1
Resident Rockstar
Resident Rockstar

Hi @Anonymous . 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-sharepoint/

 

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!


Anonymous
Not applicable

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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,044)