Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

Copy files between SharePoint libraries (Power Automate)

Posted on July 1, 2020January 12, 2022 by Tom

Copy files one by one can be painful if you’ve got a lot of them or if you need to do it regularly, there has to be a way how to automate this with Power Automate.


Let’s build a simple workflow to copy all files from one location to another on user request. That means we want to start from Instant flow using Manually trigger flow trigger.

Add New step: ‘Get files (properties only)’ and select the source of the files.

Add New step: ‘Copy file’. Select the source site, and use the ‘Identifier’ output from ‘Get files (properties only)’ as the ‘File to Copy’.

Select ‘Destination Site Address’ and for the ‘Destination folder’ fields. Instead of using dynamic content in the field click on the folder icon on the right side to display selection of all available libraries on the destination site. Also select what should happen it file already exists on the destination site.

copy files power automate
copy files power automate

Now you can find it under My flows and run it by pressing the Play button.

copy files power automate

If your document library contains also folder structure, you might need to add one more condition into the Power Automate flow to copy the folders together with the files, and even keep them synchronised in the future.

You can also copy files between multiple libraries in a single flow with a simple configuration list, or copy the created and modified information.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

26 thoughts on “Copy files between SharePoint libraries (Power Automate)”

  1. Angus says:
    June 23, 2021 at 5:49 am

    This is great except it copied all the files and nested folders from one site and placed them all in the root folder of the destination. Is it possible to maintain the folder structure during the copy?

    Reply
    1. Tom says:
      June 27, 2021 at 9:11 pm

      Hello Angus,
      I think you’ll need to go folder by folder, ‘Get files’ from one folder, ‘Copy file’ to the same folder on the other site. And repeat that for all the folders.

      Reply
    2. Tom says:
      July 7, 2021 at 7:15 pm

      Hello Angus,
      I played with the flow a bit and found a solution for the folder structure: https://tomriha.com/how-to-copy-sharepoint-files-including-folder-structure-in-power-automate/

      Reply
  2. Lucas says:
    August 26, 2021 at 5:00 pm

    Hey guys.
    My work team changes the file title with the current date at the end.
    How do I copy the file that changes the title every time?

    Reply
    1. Tom says:
      September 1, 2021 at 7:30 pm

      Hello Lucas,
      I believe the solution would be the same, if you build a flow to take all the files and copy them to another location then the file name doesn’t matter, it’ll create a file with the same name, with the date at the end, in the target location.

      Reply
  3. Josef says:
    October 5, 2021 at 5:04 pm

    Great article Tom! I was looking for a long time for a way to copy SharePoint files (or actually SharePoint pages from the Site pages library) with Flow. This works great (for the library name, just enter the library GUID) 🙂

    Reply
  4. UB says:
    October 10, 2021 at 12:52 pm

    Thanks for sharing. I have a question, is there a way to retain the date created and modified dates from the original library?

    Reply
    1. Tom says:
      October 13, 2021 at 8:28 pm

      Hello UB,
      I would recommend to create a separate SharePoint columns for the information as described in the latest post: https://tomriha.com/copy-files-including-created-and-modified-date-with-power-automate/.

      Reply
  5. Harsh Deshmane says:
    January 20, 2022 at 3:48 am

    Hi,
    Is there a way to trigger the copying when there is any change in the source folder ?
    thanks

    Reply
    1. Tom says:
      January 23, 2022 at 5:33 pm

      Hello Harsh,
      yes, it is. I wrote a blog post about such flow here: https://tomriha.com/synchronise-sharepoint-libraries-with-folder-structure-in-power-automate/, all you have to add is to select a specific folder in the trigger.

      Reply
  6. leonardo says:
    January 25, 2022 at 1:42 am

    I keep getting a URL not valid error in the target tenant. I gave bi-lateral permissions to each tenant as well and nothing. is there another step in in there that I am missing?

    Reply
    1. Tom says:
      January 29, 2022 at 6:58 pm

      Hello Leonardo,
      Power Automate flows work only in a single tenant, you can’t use it to copy files between multiple tenants.

      Reply
  7. kurt says:
    April 1, 2022 at 10:26 pm

    Thanks, Tom for the excellent articles – I’m just getting started, and your posts are helping me quite a bit.
    I think there have been some changes since you originally wrote this article, so here’s what I’ve learned from working on this. My use case is to copy a multi-level folder structure (with files) from one SharePoint Library to one in a different SharePoint site.

    First, in your ‘Get Files (properties only)’ step, if you choose ‘Include Nested Items’ = No, then you’ll only get the top level folder (both files and folders), and no longer any need to write the condition statement that you show in your article: https://tomriha.com/how-to-copy-sharepoint-files-including-folder-structure-in-power-automate/

    Second, using ‘Copy file’ on all items, I was getting a ‘File Not Found’ error on the folders. It still worked (copied all files and folders including subfolders), but just reported that it failed every time.

    The solution was to add a condition inside the ‘Apply to each’ loop: IsFolder is equal to true, and use Copy folder if true, else Copy file.

    This works great with no errors, copying the full tree.

    Thanks again for your great content. Keep it coming!

    Reply
    1. Tom says:
      April 6, 2022 at 10:12 pm

      Hello kurt,
      thank you for sharing your solution, I totally forgot about the possibility to not include the nested items, that simplifies the solution a lot.

      Reply
  8. Pruthvi says:
    April 13, 2022 at 8:34 am

    Hello I had used the same steps to get the work done but my flow is getting failed with the error stating ” response not in json format” but the files are getting moved can anyone help, thanks in advance.

    Reply
    1. Tom says:
      April 13, 2022 at 2:46 pm

      Hello Pruthvi,
      I’ve seen the error already a few times and I have no idea how to handle it, it says that SharePoint sent back an unexpected response, but it copies the file anyway. I’d probably ignore it if you’re using the flow for a one-time copy.

      Reply
  9. Mridul says:
    June 6, 2022 at 12:29 pm

    Hi Tom,
    I have followed the steps, but in my case i want to copy the Pages from Site Pages of one sharepoint site to another sharepoint site. I tried but i am getting an error that states ‘the query cannot be completed because the number of look up columns it contains exceed the lookup column threshold’. I tried to increase the threshold but in the library setting of site pages i wasn’t able to get the pagination option, however, the threshold and pagination option does appear in Document library settings. Would be great if you can help me out. Look forward to your email.

    Reply
    1. Tom says:
      June 12, 2022 at 8:41 pm

      Hello Mridul,
      Google returned this article: https://www.c-sharpcorner.com/article/msflow-lookup-columns-exceed-the-threshold-enforced-by-adminstrator/

      Reply
  10. Jennifer says:
    June 8, 2022 at 6:26 pm

    This works great, however, it stops at 100 files. It won’t go beyond that.

    Reply
    1. Tom says:
      June 12, 2022 at 8:48 pm

      Hello Jennifer,
      it’s because the ‘Get items’ and ‘Get files’ actions have a limit of 100 items (https://tomriha.com/how-to-get-over-100-items-limit-with-the-get-items-in-power-automate/). Even though the ‘Top Count’ says ‘Default = all’ in reality it’s ‘Default = 100’. Just put a higher number in there.

      Reply
  11. Edgar says:
    June 23, 2022 at 1:17 pm

    Hello, is it possible to copy the files with their associated metadata? And not just the file itself..

    Reply
    1. Tom says:
      July 3, 2022 at 11:43 am

      Hello Edgar,
      if the metadata is not included then you can use ‘Update file properties’ to compy the metadata.

      Reply
      1. Mike says:
        July 5, 2022 at 9:08 am

        Hello Tom, Edgar,
        I’m using “Update file properties” to update metadata after the copy file, it works great but the issue is it generates 2 file versions in history…Since we are using this process for DMS (safe source of important documents), it causes issues in audits we have on file generation…I could not get around it.
        If I’m using SP.MoveCopyUtil.CopyFileByPath() in a REST API call, file get copied but history is deleted.
        If I’m using CreateCopyJobs in a REST API call, file gets copied but it’s also copying source version history….
        I don’t know if you came around this? Thanks

        Reply
        1. Tom says:
          July 12, 2022 at 4:38 pm

          Hello Mike,
          you could try to update the properties using an HTTP request as described here: https://tomriha.com/update-sharepoint-column-without-new-item-version-in-power-automate/

          Reply
  12. Cheryl Lee says:
    October 5, 2022 at 5:23 pm

    Hi,
    I may have missed the comments. My flow works and it does copy files from one sharepoint folder to the other. All the files will keep their names.

    However, in the the destination, all the version history disappears. Is there a way to retain it?

    Reply
    1. Tom says:
      October 14, 2022 at 10:23 am

      Hello Cheryl,
      you can’t copy the old version history of the original file, it takes only the currently available version. But it’s possible to update the destination file instead of replacing it during the copy action as explained here: https://tomriha.com/how-to-update-not-replace-an-existing-file-in-power-automate/

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes