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 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,394 Most Valuable Professional on at

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

  • Sundeep_Malik Profile Picture
    6,484 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
    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,394 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
    68,697 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,484 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

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard