Copy a from a source library to a destination library a document and any folder structure it may sit inside of. The folder names will not be known

We have several SharePoint document libraries. Each one contains randomly generated folders, and inside those folders are many files.

I need to use Microsoft flow to manually copy the contents of one library to another library.

For example, the Subsite contains a document library called account

The document library called accounts contains many folders and files, and inside each folder may exist subfolders and files.

I need to copy everything in account, including the subfolders and files, exactly as it exists in the subsite above, to the destination

How can I do this with Plumsail?

The examples I found seem to show doing it with a single known folder or file, and these are random and we will never know them. We just need to get EVERYTHING regardless of what is it named. And we need to preserve the folder structure and folder names.

I can do this in Flow but the microsoft component won’t copy any of the folders so thousands of documents that are in folders and subfolders end up in the root of the library, so thats why we are turning to look at Plumsail.

Another way to go about it would be to trigger a workflow on the creation or modification of a document, the workflow would need to create in the destination library, any source folders the document might sit in, within the source library, then copy the source file from the source library to the destination library so that it sits in the exact same folder in the destination.

Does anyone have an easy to understand step by step instruction on how to do this?


For that purpose you can use our Action "Get SP items by CAML query". Still you'll need to copy folders and files seperately. Here's an example of how you can do it:

So, at first get all the folders from your library:

Then, copy them:

Do the same for files (get, the copy):

Pay attention to the CAML Query (the second query differs from the first so, that it excludes folders - " ").
Here's the query for copying:

            <FieldRef Name='ContentType' />
            <Value Type='Computed'>Folder</Value>
    <FieldRef Name="FileRef"/>
    <FieldRef Name="FileLeafRef"/>

You can find more information about it here.

As for "Another way" you described - you can just create two simple flows for copying (folder/file) to another library trigered when the file is modified or created. Here's an example:

Best regards, Kirill Shaklein

I am trying the “Another way” / second option that is comprised of two steps but I am getting a “BadRequest” error.

The error details are “Cannot create an item at the requested destination. Verify that the folder exists and that you have permission to edit in it.”

The PlumSail SP Account has permissions. Its the same account I used with the Microsoft Flow version that copies the documents but not the folder structure.

The error is shown as follows in the outputs section:


Source URL

Destination URL

SharePoint Site URL

Status code
Fri, 21 Sep 2018 15:37:47 GMT
__cfduid=db5f2b3a064f1aded71bbecff684f10de1537544266; expires=Sat, 21-Sep-19 15:37:46 GMT; path=/;; HttpOnly
application/json; charset=utf-8
“request”: {
“url”: null,
“traceId”: “0HLGV70VG3V9I83c1c845”
“error”: {
“code”: “ApplicationResultException”,
“message”: “Cannot create an item at the requested destination. Verify that the folder exists and that you have permission to edit in it.”,
“date”: “2018-09-21T15:37:47.1098876Z”


Yes, the error occurs because there’s no destination folder existing. We’ve try to fix this problem on our side.

And we’ll get back to you. Thank you for patience

Best regards, Kirill Shaklein