cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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

 

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

9 REPLIES 9
Highlighted
Super User III
Super User III

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

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
Highlighted
Frequent Visitor

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

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.

 

 

Highlighted
Super User III
Super User III

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

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
Highlighted
Frequent Visitor

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

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

 

 

 

 

 

Highlighted
Super User III
Super User III

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

@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
Highlighted
Frequent Visitor

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

Still didn't work, unfortunately.

 

Flow Example 2.png

Highlighted
Super User III
Super User III

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

@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
Highlighted
Community Support
Community Support

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

 

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

Highlighted
Frequent Visitor

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

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,

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,244)