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 / File not found error w...
Power Automate
Unanswered

File not found error with Copy and Delete File actions

(0) ShareShare
ReportReport
Posted on by 15

Hi all,


I'm trying to finalize a Flow and are ecountering an error and a strange behaviour.


The Flow rationale is as follows:

1) When a new file is created on a Sharepoint Site and is a Folder and starts with one of two specific strings, do as follows:

2) Copy in this new folder a subfolder from a master folder with a fixed address

3) Retrieve a string in brackets from the new folder name 

4) Search for another folder in the repository whose name is exactly the string recovered from the brackets

5) From this folder, copy a specific subfolder to the folder that originally triggered the flow

6) Delete the folder from step 5

 

Flow looks as follows:

 

Flow1.jpgFlow2.jpgFlow3.jpgFlow4.jpgFlow5.jpg

 

The flow fails on the last two steps and gets the following error:

 

Flow6.png

 

BUT, it actually manages to copy the subfolder content (the second Copy folder step) to the folder, even thou the step gets flagged as failed.

 

Any ideas on what's wrong?

 

Thanks

Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @MGiles Here are a few recommendations I would make for your flow. 

    Trigger Conditions

    I would recommend that you add a Trigger Condition to your flow. If I'm understanding your flow correctly, you only want to trigger this flow if a folder that starts with JOB_2 or RAP_2 is created. 

     

    For testing purposes, create a new flow. This way you can run a test and ensure you've set up the trigger conditions correctly before editing your current flow. 

     

    Click on Settings

    creativeopinion_0-1704774330019.png

     

    Scroll down to the bottom.

     

    creativeopinion_25-1704777651462.png

    Insert this expression. 

    @and(equals(triggerOutputs()?['body/{IsFolder}'], true), or(startsWith(triggerOutputs()?['body/{Name}'], 'JOB_2'), startsWith(triggerOutputs()?['body/{Name}'], 'RAP_2')))

     

     

    You need to add at least one other action. For testing purposes, add a Compose action and select any dynamic content. For my test, I selected the Name dynamic content from the flow trigger—this way I can verify the name of the folder created.

    creativeopinion_2-1704774652917.png

     

    Run a test. First, try to:

    • Create a file in your document library
    • Create a folder that does not start with JOB_2 or RAP_2

    See if your flow triggers (it shouldn't). Next, create a folder that starts with either JOB_2 or RAP_2. The flow should trigger. 

    creativeopinion_7-1704775545912.png

    Replace Variable with a Compose Action

     

    It doesn't look like you are setting your Variable anywhere in your flow (unless I'm missing something). For that reason ... I would recommend using a Compose action instead.

    creativeopinion_5-1704774948832.png

    Tip: Rename your actions to keep your flow organized. It's a lot easier to identify which dynamic content belongs with which action when they are named properly. 

     

    Manually Triggered Flow for Testing

    I would recommend creating a new manually triggered flow for testing. Anytime you are building a flow with an automated trigger—start with a manually triggered flow. This can help to speed up your flow building/testing process as you don't need to trigger your flow by creating a file/folder, sending an email, filling out a form etc. 

     

    Also, by having a manually triggered flow—you can make modifications and test it out while triggering it manually and then make changes to your live flow. It's also a lot easier to run tests and troubleshoot early rather than after your entire flow is built. 

     

    creativeopinion_8-1704775667596.png

    Compose Folder Id

    Add a Compose action to store the ID from the Get folder metadata action. You'll see why near the end of the flow.

    creativeopinion_11-1704776169929.png

    Copy Folder

    I believe your Copy Folder action isn't set up correctly. The Current Site Address should be the site where the folder (that was created) is currently.

     

    In the Folder to Copy field, insert the output from the Compose action above. 

     

    For the Destination Site Address, select the site where you want to copy the folder to. This can be the same site or a totally different SP site.

     

    For the Destination Folder, select the folder in which you'd like to Copy the Folder to. 

    creativeopinion_12-1704776208002.png

    Run a test. Verify that your folder was copied.

    List Folder

    Instead of a Get Files (properties only) action I would recommend using a List Folder action—since you are looking for a folder not a file.

    creativeopinion_13-1704776673116.png

    Also, the Apply to each action (that you have in your current flow) isn't necessary if you are only returning a single folder. You might find this YT Tutorial helpful: 3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow

    Filter Array

    Add a Filter Array action. In the From field, insert the Body dynamic content from the action above.

    creativeopinion_14-1704776716232.png

     

    In the first value field, insert the Name dynamic content from the List Folder action. Leave the operator to is equal to. In the second value field, insert the output from the Compose action that is storing the string of text you'd like to search for.

    creativeopinion_15-1704776839119.png

     

    To learn more about how to use the Filter Array action, please refer to this recent YT Tutorial I uploaded.

     

    Return Filter Array Count

    Whenever I use a Filter Array action, I always like to return the count of items returned in a Compose action. This is helpful when building a flow and can also be used to troubleshoot your flow. Insert a Compose action.

     

    Add an Expression. Use the length() function.

     

    creativeopinion_16-1704776943358.png

    Select the Dynamic content tab and insert the body dynamic content from the Filter Array action into the length() function.

     

    creativeopinion_18-1704776961561.png

    Run a test. Verify the output of the Compose action storing the Folder Count is 1. 

    creativeopinion_20-1704777113123.png

    Condition Check

    Add a Condition action to check if the Filter Array action has returned a folder. There isn't a point to continue on with your flow if there isn't a folder that matches your requirements.

     

    Insert the output from the Compose action into the first value field. Change the operator to is not equal to and enter zero into the second value field.

    creativeopinion_21-1704777179457.png

    The rest of your actions can go into the Yes branch.

     

    Compose Folder ID from Filter Array

    Unfortunately, when you use the Filter Array action the dynamic content form it isn't available to select from. You'll need to use an expression. Add a Compose action to store the Folder ID returned from the Filter Array action.

    creativeopinion_8-1704779217180.png

     

    View the Filter Array output from your previous flow run. For the expression you'll need the dynamic content key. 

     

    creativeopinion_22-1704777459857.png

    In the Folder to Copy field insert an expression. Start with the following:

    ?[0]['']

    The Filter Array action will always return an array of items. To select the first item, we'll use the [0] index. 

     

    Enter the dynamic content key between the single quotes. In this case you need the Id. Enter Id between the single quotes. Please note, the dynamic content key is case sensitive.

    creativeopinion_9-1704779360258.png

     

    Place your cursor at the start of the expression and select the Dynamic content tab. Insert the body dynamic content from the Filter Array action.

     

    creativeopinion_4-1704778534028.png

     

    Copy Folder

    Your current flow has a Copy File action. This may have been an error or I might be missing something. I'm under the impression you want to copy the folder. In which case, you'll need a Copy Folder action.

     

    For the Folder to Copy, insert the output from the Compose action above.

    creativeopinion_11-1704779514541.png

     

    For the Destination Site Address, select the site you'd like to Copy the folder to. From your post, it should be the site that triggered the flow. In this particular demo, it should be the same site selected in the Get folder metadata action.

     

    For the Destination Folder. You indicated that you want to Copy this folder to the folder that originally triggered the flow (not the copied folder—correct?) If that is the case, you'll need to select the Path dynamic content from the Get folder metadata action (for this demo)—for your flow it would be from the Flow trigger. 

     

    We'll adjust the trigger of this flow near the end... 

    creativeopinion_12-1704779577778.png

     

    Run a test. Verify the folder has been copied to the correct location.

     

    .....More to come. Ran out of time tonight.

     

    Error Handling

    Keep in mind that you might want to build in error handling for the Copy Folder actions. I'm not sure if there will ever be a case where the folder might already exist. Otherwise your flow will fail.

     

    creativeopinion_19-1704777042422.png

     

     

     

    For more flow troubleshooting tips—check out This YT Tutorial: 5 Power Automate Troubleshooting FAQs and Helpful Tips for Creating Better Flows

    In this tutorial I cover:

    ✅ How to troubleshoot a false Condition action result

    ✅ How to get dynamic content when it isn’t selectable from the list of dynamic content

    ✅ How to troubleshoot an Apply to Each action that isn’t looping through

    ✅ How to troubleshoot a skipped Apply to Each action

    ✅ How to troubleshoot a Filter Query

    ✅ How to use a SharePoint yes/no column in a Filter Query

    ✅ How to use Compose actions to troubleshoot a Power Automate flow

    ✅ How to troubleshoot multiple emails being sent

    ✅ How to troubleshoot multiple Teams messages being sent

     

     

     

     

  • MGiles Profile Picture
    15 on at

    Wow!! Many thanks for the reply!

    I see many improvements coming from your suggestions and some solutions to steps I wasn't able to handle (I don't like the apply to each and would have preffered using the Array Filter but couldn't get it to work).

     

    I'll start testing what you propose and let you know the outcome.

     

    Take care!

  • MGiles Profile Picture
    15 on at

    Ok, I've been trying with your proposed solution and I'm stuck at the first step for two reasons:

     

    1) Addying the "Compose - Name" step triggers and "Apply to Each"

    2) I've tried to trigger the flow as you suggested but the flow does not run

     

    New Flow.jpg

  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @MGiles To clarify, my original post was two fold. The first section was to test and verify that a Trigger Condition would work for your final flow. The rest of the post goes through how to build and test out a flow based on your original requirements. 

     

    It's odd that the Name dynamic content is automatically adding an Apply to Each action—it doesn't do that for me. Have you started editing your flow in the Classic or New Designer. If you've started editing your flow in the New Designer then switched over to the Classic, I would recommend scrapping the flow and creating a new one and editing in the Classic Designer. The New Designer has some bugs still. 

  • MGiles Profile Picture
    15 on at

    @creativeopinion , Thanks again for your reply.

     

    So, I've redone the flow following your guidance (and using the Classic Designer! Indeed, I was using the New Designer..)

     

    I've been able to get to the last steps but I'm stuck with the following error:

     

    "Non è stato possibile verificare l'esistenza dell'oggetto di origine in "https://xxxxxxxxxx.com/sites/BC/387505" a causa dell'errore "The system cannot find the file specified. (Exception from HRESULT: 0x80070002)".
    clientRequestId: dc6c29c0-0297-4b08-908a-54a38af56449
    serviceRequestId: dc6c29c0-0297-4b08-908a-54a38af56449"

     

    I'll paste here some screens of the current flow:

     

    Newflow1.jpgNewflow2.jpgNewflow3.jpgNewflow4.jpgNewflow5.jpgNewflow6.jpg

     

    I still had tu use a Get Files instead of List Folder because List wasn't returning all subfolders in the specified folder.

     

    This are the results from the last two steps:

     

    Flowerror.jpg

     

    Once again, thanks for all your support!

  • Verified answer
    creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @MGiles If you need to use the Get files (properties only) action, then the Filter Array action isn't necessary. You can use the OData filter query instead.

     

    You'll need to insert the output from the Compose action between single quotes.

    creativeopinion_6-1704844667138.png

     

    You will need to ensure you are using the proper internal name column for your column in your SP Document Library. If you aren’t sure how to get this, please refer to this section of one of my YT tutorials.

     

    Delete Unnecessary Actions

    You can delete these two actions as they aren't needed.

    creativeopinion_1-1704844089510.png

     

    Replace Filter Array Dynamic Content References

    Insert the value dynamic content into the length() function of the Compose action.

    creativeopinion_2-1704844137946.png

     

    Replace the reference to the Filter Array body in the Existing Folder ID Compose action with the value dynamic content from the Get files (properties only) action as well. The dynamic content key will also need to be updated as the ID dynamic content key in from the Get files (properties only) action is ID, not Id. 

    creativeopinion_1-1704853844843.png

     

    Compose the Identifier

    Create another Compose action to store the Identifier which you'll need for the Copy folder action.

    Insert an expression.

    creativeopinion_2-1704853915063.png

    For your reference, this is the dynamic content key.

    creativeopinion_7-1704844755727.png

    Place your cursor at the start of the expression and insert the value dynamic content from the Get files (properties only) action. 

    creativeopinion_3-1704853995336.png

     

    Adjust the Copy Folder Action

    You'll need to replace the output in the Folder to Copy field with the output from the Existing Folder Identifier Compose action (the one that was just created). 

    creativeopinion_4-1704854056447.png

    Run a test. 

     

    Delete Folder

    Add a Delete Item action. Although there isn't a Delete Folder action, the Delete Item action can be used instead.

    For the List Name, select Enter Custom Value.

    creativeopinion_6-1704854199222.png

     

    You will need to manually enter the Document library name into the List Name field.

     

    Insert the Output from the Compose action above that is storing the ID. Note: This is why it's important to rename your actions... especially when you need to use the dynamic content in other actions. It makes it easier to identify which dynamic content belongs to which action. 

     

    creativeopinion_5-1704854168378.png

    Run a test. Note how the Delete Item action requires a numerical Id.

    creativeopinion_7-1704854382788.png

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response!

    👉 Watch my tutorials on YouTube
    👉 Tips and Tricks on TikTok
  • MGiles Profile Picture
    15 on at

    @creativeopinion I don't know how to thank you! The flow now works perfectly!!!

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