cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
M-Herz
Frequent Visitor

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

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,

1 ACCEPTED SOLUTION

Accepted Solutions

 

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,

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

View solution in original post

10 REPLIES 10
ChristianAbata
Super User
Super User

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

 

https://powerusers.microsoft.com/t5/Building-Flows/delete-empty-folders-in-sharepoint-document-libra...

 

shure this could help you.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

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.

 

 

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



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
M-Herz
Frequent Visitor

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

 

 

 

 

 

@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.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Still didn't work, unfortunately.

 

Flow Example 2.png

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



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

 

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,

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

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,

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 ?

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,085)