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

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

(SharePoint) When a new file is created in X folder, delete existing file in Y folder, and copy new file to Y folder

(0) ShareShare
ReportReport
Posted on by 2

Hello everyone,

 

I'm looking to do the following:

When I drag a file into the trigger folder X, delete the existing file in folder Y, and copy the new file to folder Y.

 

Folder Y contains the latest file, and folder X contains all versions of this file which have the same name but a different date (i.e. ThisIsATest 4-30-20).

 

Potential Bugs:

1. The "When a file is created in a folder" trigger is only triggering when I literally create a new file in that specific folder. It doesn't work when I drag in an existing file into that folder. But dragging works consistently with a different flow in a different area of SharePoint (sends out an email).

 

2. The "Replace" option for the "Copy File" action doesn't seem to work. It will copy the file over completely, but not remove the file already inside.

 

Any insight into this and/or the bugs? Thank you for your help.

I have the same question (0)
  • v-litu-msft Profile Picture
    on at
    Re: (SharePoint) When a new file is created in X folder, delete existing file in Y folder, and copy new file to Y folder

    Hi @LetItFlow,

     

    Which step have you done now? Have you accomplished rename the file with a different date?

    For potential bug 1, actually, the trigger will work just like its name, when a new file is created, if the file already existed in the library, it will not trigger the Flow. 

    https://docs.microsoft.com/en-us/connectors/sharepointonline/#when-a-file-is-created-in-a-folder

     

    For potential bug 2, it will work if your configuration is correct. When a file is copied into a folder, it will compare the copied file with existing files in the folder according to their file name, not content.

     

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

  • LetItFlow Profile Picture
    2 on at
    Re: (SharePoint) When a new file is created in X folder, delete existing file in Y folder, and copy new file to Y folder

    @v-litu-msft Good morning and thank you for your response. Please see the photo attached.

     

    Flow1.png

     

    My success has been limited. With this flow, I have only been able to copy a file that was created (not dragged in) in the trigger folder into the target sub folder of the trigger folder. By doing so, it doesn't replace the existing file with a different date in the target sub folder.

     

    For potential bug 1, I may understand now. I have a few other flows that send an email when a file is created in different folders than my current target folder. These have ran successfully with this same trigger with files already made in the library. Although, perhaps this is because we drag a copy (CTRL+click and drag) to the trigger folder and it sees this as a brand new file. Thank you for clarifying this for me.

     

    For potential bug 2, are you saying that only if they share the same name will the file replace the existing? So it must be "ThisIsATest" to replace "ThisIsATest" instead of "ThisIsATest 5-4-20" to replace "ThisIsATest 5-3-20"? If this is the case, is it possible to do this: When a file is created -> Copy to target folder and rename the copy to "ThisIsATest" and replace the existing

     

    Thank you for your help so far.

  • v-litu-msft Profile Picture
    on at
    Re: (SharePoint) When a new file is created in X folder, delete existing file in Y folder, and copy new file to Y folder

    Hi @LetItFlow,

     

    Yes, when you create a new version of the file, you could create it in another folder, then copy it to the destination folder, then the original file in the destination folder will be replaced.

     

    Best Regards,
    Community Support Team _ Lin Tu
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 666 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 382 Moderator

#3
developerAJ Profile Picture

developerAJ 254

Last 30 days Overall leaderboard