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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Delete files in ShareP...
Power Automate
Unanswered

Delete files in SharePoint

(0) ShareShare
ReportReport
Posted on by 31

I have set up a copy job in SharePoint from one location to another and it is working. I want to create a delete function that should delete files in the destination if any files are deleted in the source location. I tried multiple methods but it's giving 404 files not found error.

Categories:
I have the same question (0)
  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    Could you include your flow design logic (screenshot) in the forum?

  • Sundeep_Malik Profile Picture
    6,501 on at

    Hey @Chalaka 

    The file has already been deleted, thats why you are getting the error.

    Sorry, but I dont know of any alternative for this.

     

     

    @Expiscornovus 

    @Pstork1

    @v-yujincui-msft 

    Any solutions?

  • Chalaka Profile Picture
    31 on at

    This was my flow.

    Chalaka_0-1663727666407.png

     

    I'm trying the below one now. Not sure if it will work or not.

    Chalaka_1-1663727723364.png

     

     

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @Chalaka ,

     

    Maybe you could try the following.

     

    1. Here are my folders.

    vyujincuimsft_0-1663727747774.jpeg

    2. Here is my Flow.

     

    FileLeafRef eq '@{triggerOutputs()?['body/FileNameWithExtension']}'

     

    vyujincuimsft_0-1663728036755.png

    vyujincuimsft_2-1663727780279.png

    Result Screenshot:

    vyujincuimsft_3-1663727850399.png

     

     

    Best Regards,

    Charlie Choi

  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    Or you could simply try using SharePoint REST API.

    See this

    Solved: SharePoint Delete file, File identifier from a lis... - Power Platform Community (microsoft.com)

     

  • Chalaka Profile Picture
    31 on at

    Thank you. I will try these suggestions and give you feedback. Also, I have missed one thing, it is not only a file, but it can also be a folder as well. Whatever the things delete in the source, the same files/folders should delete in the destination. 

  • Pstork1 Profile Picture
    69,159 Most Valuable Professional on at

    Yes it is possible.  The key is that the file Identifier is an encoded version of the path.  So if I have a variable called varFolder contains the base path for the destination file folder then the file identifier would be

    encodeUriComponent(concat(variables('varFolder'),'/',triggerOutputs()?['body/FileNameWithExtension']))

    image.png

  • Chalaka Profile Picture
    31 on at

    I tried this and it works for the files 😊 but it does not work if we delete a Folder. Any suggestions? 

  • Chalaka Profile Picture
    31 on at

    Hi,

     

    Could you please put a screenshot of how initialize variable should be? I tried but the variables are not picking up correctly. 

  • Sundeep_Malik Profile Picture
    6,501 on at

    @Chalaka 

    Can you show what error you are getting or what are you putting in the expression. Maybe you are making a mistake there?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 612

#2
Valantis Profile Picture

Valantis 344

#3
11manish Profile Picture

11manish 326

Last 30 days Overall leaderboard