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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Delete a file in a fol...
Power Automate
Answered

Delete a file in a folder when a file of the same name is created in a different folder

(0) ShareShare
ReportReport
Posted on by 21

Hi,

 

I have been trying to build a flow so that when a file in folder B is created, folder A is checked for a file with the same name and deletes it.

 

Any idea how to do it?

 

Regards,

Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @M-Herz  recently delete folder scenario was solved see

     

    https://powerusers.microsoft.com/t5/Building-Flows/delete-empty-folders-in-sharepoint-document-library/m-p/587608#U587608

     

    shure this could help you.

  • M-Herz Profile Picture
    21 on at

    I want to delete files such as pdf and words documents with the condition of having duplicate names, the post you referred to is about delete folder with the condition of them being empty. Sorry, but I don't see how it can help me in my issue.

     

     

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    ohhh @M-Herz  ok, mmm what you need to do is use condition action, to find a specific file name then you can delete it with the action delete file (sharepoint).

     

    Like an action to list every file with repeating name does not exist my friend

  • M-Herz Profile Picture
    21 on at

    I have tried the below:

    1- Trigger: When a file is created in a folder.

    2- Then: List Folder to get the content of the folder

    3- Then: Filter Array to try reach the file I want to delete.

    4- Then: Delete file

     

    But it is not working, specifically filter array is not picking up anything.

     

     

    Flow Example.png

     

     

     

     

     

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    @M-Herz  you file name in filter array is from the trigger when a file is created?

     

    Because see Item is an array propertie that means you have lots of values there, so you need to compare File name with file name to get results.

  • M-Herz Profile Picture
    21 on at

    Still didn't work, unfortunately.

     

    Flow Example 2.png

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    @M-Herz  do you have now values in filter array?

  • Verified answer
    v-bacao-msft Profile Picture
    on at

     

    Hi @M-Herz ,

     

    Please try the following configuration and check if the body of Filter array is empty array.

    47.PNG

    @equals(toLower(item()?['DisplayName']), toLower(body('Get_file_metadata')?['DisplayName']))

     

    Hope this helps.

     

    Best Regards,

  • M-Herz Profile Picture
    21 on at

    Hi,

     

    Your solution solved the problem, and now the flow works as intended, but I don't understand why? is it because of the metadata? I appreciate if you can explain.

     

    Again thanks a lot for the help.

     

    Regards,

  • dmooreii Profile Picture
    98 on at

    I am trying to accomplish same outcome but not working for me.

    It is deleting all files in folder A and then gives a "file not found" error.

    I just need some more info on the flow.

    Get file metadata would be the path to the new file in folder B correct ?

    What info is needed in List folder step ?

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard