Skip to main content

Notifications

Power Automate - Using Connectors
Answered

Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

(0) ShareShare
ReportReport
Posted on by

I am trying to create a Power Automate flow for my SharePoint structure to help manage version updates of files saved in multiple locations.

 

I want to have a master folder where files  will stored and modified. When a file is modified I want Power Automate to search another SharePoint folder (and its subfolders) for files of the same name and then overwrite these existing files with the one from this master folder. There will often be 2 or 3 files with the same name (identical files jsut saved in multiple places) so I need it to check all the files in all the folders of that SharePoint location and not just stop after the first file.

 

I can see how to add new files or modify exsiting files in a specific folder, but can't see anything about searching/checking to see if that filename already exists and overwriting it if it does within a SharePoint folder and it's subfolders.. any help on this would be appreciated! Thanks

  • hgartner Profile Picture
    hgartner 65 on at
    Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    I did this test and the file is updated in the folder, but the content of the file is not, because when clicking on the file to view it, it gives an error when loading the file.

     

    Do you know why?

  • Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    @v-alzhan-msftI have now got this working. I was pointing to "Library 1" instead of "Library 2" in the Update File action - d'oh!

     

    Thanks very much for your help

  • Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    @v-alzhan-msftbelow is the details of a successful run where the Exist function was true, however the content of the file remains blank despite the "Library 1" file having text added to it.

     

    flow error.png

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Here is how I set up the flow (as per your instruction)

    flow error marked.png

     

    Thanks for the continued support

  • Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    Hi @Anonymous ,

     

    Please share the screenshot of the run history for when the file in exist however the file wouldn't update.

    The flow would work if you have choose the correct dynamic content.

     

    Best Regards,

    Alice

     

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    Thank you for the help with this. This has worked for creating new files but it doesn't seem to be working for updating the content of existing files already in the 'library 2' folder

     

     

    Below is what I put for that section:

    flow.png

  • Verified answer
    Re: Search a SharePoint folder (& subfolders) for a filename. Replace file if name exists, create file if name doesn't.

    Hi @Anonymous ,

     

    You could refer to screenshot below to create the flow between two libraries:

    1.png2.png3.png

     

    Best regards,

    Alice   

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,567

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard

Featured topics