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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Wrong path when using ...
Power Automate
Unanswered

Wrong path when using Create file in Sharepoint automation

(0) ShareShare
ReportReport
Posted on by 11

Hi all

 

I have a hard time trying to automate a copy of files from one Sharepoint to another Sharepoint. I've read somewhere that "Copy file" should not be used between Sharepoint, although it seems to work fine when copying to a single destination folder on the destination Sharepoint.

My objective is to copy each file to the same folder structure on the destination as the source. i.e. SharepointSite1/folderA/fileA should become SharepointSite2/FolderA/fileA.

I have tried different approaches for setting the path and file name, using "Path", "Full path", "Folder path" for the path, and "File name", "File name with extension", "Name" for the file name itself.

All of these fails in some way and screws up the path on the destination.

 

For example, from execution of the flow I get this path:

"Path": "/Collaboration Processes Tools/Auto-copy from IMS & Mobile Core/IMS Core/IMS Core/User profiles and triggers in IMS.docx/User profiles and triggers in IMS.docx"

The correct one would be:

"Path": "/Collaboration Processes Tools/Auto-copy from IMS & Mobile Core/IMS Core/User profiles and triggers in IMS.docx"

 

Categories:
I have the same question (0)
  • DeepakS Profile Picture
    2,301 Most Valuable Professional on at
    Re: Wrong path when using Create file in Sharepoint automation

    Hi @sblar 

    copy file required absolute correct path (even one extra / will fail the copy function). 

    as you explain that source and destination library has same folder structure here is what you should do to successful copy:

     

    CopyFile.png

    Source Path: triggerBody()?['{Path}']

    Destination location - substring(triggerBody()?['{Path}'],0,add(length(triggerBody()?['{Path}']),-1))

     

    Please note my flow trigger on file added so i am not passing file name as it runs only for given file. let me know if this scenario does not works for you

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

     

  • sblar Profile Picture
    11 on at
    Re: Wrong path when using Create file in Sharepoint automation

    Hi DeepakS

     

    Copy file gives:
    {
    "status": 400,
    "message": "Eksistensen af destinationsplaceringen på \"https://xxx.sharepoint.com/sites/xxxxxx/Collaboration Processes Tools/Auto-copy from IMS & Mobile Core/IMS Core/SBC/Ericsson SBG\" blev ikke bekræftet på grund af fejlen \"The system cannot find the file specified. (Exception from HRESULT: 0x80070002)\".\r\nclientRequestId: ace72002-9aa6-4015-8f86-757d0f8296db\r\nserviceRequestId: ace72002-9aa6-4015-8f86-757d0f8296db"
    }

     

    From what I can find on-line, this seems to be a known error and why you need to use "Create file" instead of "Copy file" when you want to copy to another Sharepoint.

    Can you adapt your solution to Create file?

     

    This is my flow (after trigger)

     

    flow.png

  • DeepakS Profile Picture
    2,301 Most Valuable Professional on at
    Re: Wrong path when using Create file in Sharepoint automation

    Hi @sblar 

     

    Copy File should work , the screen capture i shared is from a working Power Automate.

    But if you want use create file you can still use the similar approach:

    catch is Folder Path - so use the expression that i share for destination folder (if its dynamic)

    File name- you can give a unique name

    File content- output of Get File content 

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • Verified answer
    sblar Profile Picture
    11 on at
    Re: Wrong path when using Create file in Sharepoint automation

    Thanks DeepakS, you're my hero 🙏

     

    It works great. Only minor problem is that path contains the actual name of the source document library, and not the visual name that I previously changed it to. I can't change the actual name since I can't get into file explorer view, but, it is a minor problem and has nothing to do with your solution - or Power Automate.

     

    Thanks again

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

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard