cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pnr
Frequent Visitor

Overwrite file if it already exist

I am having a flow where I convert some Word documents to PDF, when the Word document are being updated or created. Then it move the PDF to another location. This is all fine, but sometimes a PDF is already on the location when the flow creates a new one (step Create file 2), and then the flow fails 😐 Isn't it possible to make so that it will overwrite the existing file, if it is already there? 

pnr_0-1612188320814.png

 

6 REPLIES 6
stephankline
Community Support
Community Support

Hello,

 

Thank you very much for the screenshot and general idea of how you'd like the flow to operate.

 

In looking at what you have so far and your proposed result, it looks as though you may be missing a Condition control to check if the pdf already exists in the destination.  The basic logic looking something like this:

 

  • If file exists equals "Yes", then delete the found file with the recently converted pdf. 
  • If file does not exist, then create file (as you already have set up in an Action).

 

To see a similar working version of this for attachments, I was able to locate another thread that used a different trigger, but the end result matching up with what’d you like to do:

 

Save attachment to One Drive and OVERWRITE an exis... - Power Platform Community (microsoft.com)

 

Community Support Team - Stephan Kline

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tom_riha
Super User
Super User

Hello @pnr ,

the 'Create file' action doesn't have a possibility to replace an existing file. I'd say you've got two options:

  1. If a file with the name already exists, delete the current file and create a new one as proposed by @stephankline .
  2. Create one more "shadow" document library on the site, create the file in the new library, and then use 'Move file' action to move the file to the main library. 'Move file' will allow you to replace the file if it already exists = Power Automate will take care of the deletion/creation of the new file in the main library.

image.png



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
JanHogerwerf
New Member

I am using the replace option and it somehow works. 

 

But what I don't like is that it moves the old file to the recycle bin instead of overwriting.

 

Some files get replaced a lot and then get many files in my recyble bin. 

 

Can it not just overwrite the existing file? And use version history if you want to see the file that has been replaced?

 

Thank you!

Hello @JanHogerwerf ,

you can, but it's a bit more work: https://tomriha.com/how-to-update-not-replace-an-existing-file-in-power-automate/



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

@tom_riha I know but was trying to avoid the extra work by using the standard function 😛

I can't even count how many hours I wasted by trying to avoid extra work... 😁



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,183)