web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Overwrite file if it a...
Power Automate
Unanswered

Overwrite file if it already exist

(1) ShareShare
ReportReport
Posted on by 18

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

 

Categories:
I have the same question (0)
  • stephankline Profile Picture
    Microsoft Employee on at

    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 Profile Picture
    10,187 Most Valuable Professional on at

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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!

  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    Hello @Anonymous ,

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have a similar issue updating a PDF file attachment in list library. 

     

    1. The update file doesn't update the file. Is this method only works for Document Library?

    RajMalot_0-1662560562716.png

     

    2. If you Delete the attachment, and Add Attachment. That results in file moved message.

    Am I doing something wrong?

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    As far as I know updating file works.

     

    Check if file exists --> If not create file. If it does exist use update. That way existing file is not sent to recycle bin.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you, I do check if file exist.

    RajMalot_0-1662562327020.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I was unable to make the update file method to work with list attachment. Hence I tried other options suggested and it works fine now.

     

    1. Get list item attachments

    2. Delete the list attachment if exists

    3. Add attachment to list item

     

    RajMalot_0-1662654055222.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard