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!


View solution in original post

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
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (48,896)