Copy SharePoint list attachment (s) to a document library using Microsoft Flow

Updated – 20 August 2019:

Since we now have a much easier way to achieve the same results, I have updated this flow (two less actions).  Mainly two changes, 1) We do not need to create a text file to create a folder. If we provide the path SharePoint will ensure that folder is created if not already there. 2) ‘Get attachment content’ action is now replaced with ‘Get file content‘ which is bit simpler.

Here are the updated screenshots:

Note the Id obtained from ‘Get attachments’ action.

Compose action with Title/Id from the item created action.  You can name anything you want but I combined title with Id this to ensure that the folder created is unique.

Note the folder name, I have the list item with User 3 (Title) and File Size confirms that files are copied correctly.

Older Version

This one is simple, yet very powerful and was only possible with the power of Microsoft Flow.  I did something similar in SharePoint 2010 and it took me at least two days to learn and implement, but with the Flow, I have a working solution ready within 30 mins.

The requirement was, user will submit a form with some attachments and these attachments/ documents will need to be reviewed and processed.  Reviewing individual files in the custom list could be very tedious (clicking one by one files) and we also don’t get the same experience as the modern library with preview etc.  It also allows the admin staff to share file easily during the review stage if needed.  We can also send multiple attachments via email using an Array action.

The Flow will trigger when an item is created in a particular list.  The first action would be get the attachments from a particular item submitted.

Next, we will loop through all the content of the attachments of the particular item.

I wanted to create a folder per item with the name of the User Name and ID (in case, there are users with the same name).  So we have compose action which gives us a path and in order to create a folder (as there is no create folder action available) we have to create an empty text file.  This can be deleted, if required, but I keep this.

Last step is to create the files in the particular folder created above.  In my case, I have also decided to copy the files into a different site collection. Yes, a different collection, imagine doing this with the SharePoint Designer!

Let’s run this by adding an item in the list.  I have four attachments submitted with this item.

All the attachment submitted were copied in a new folder called User Name – ID (SharePointer-30), I am using a default ID provided by the custom list as it is auto numbered and unique.

Please follow and like us:


GR · July 4, 2018 at 15:43

Hello 🙂

Thanks for this!!

I have tried the same with your instructions and it works, except that it just creates the readme file and does not include the other files I attach to a list item. The flow shows a “success”. Also, when I add more than one file, it will not even create a readme as it says that there was no content, flow is still a success though.

Any idea why this happens?


    SharePointer · July 17, 2018 at 19:18

    Make sure you are adding ‘Attachment Content’ in the File Content area. I think this is because the file has no content.

      Mike · March 5, 2019 at 10:02

      Hello Sharepointer
      On the second create file step ‘Attachment Content’ is not displayed on the dynamic content.I cannot find what went wrong. Do you have any idea???

        SharePointer · August 22, 2019 at 15:22

        Updated the blog which might be helpful.

Danielle · August 24, 2018 at 15:03

Trying to do something similar, except mine when item is created I start an approval, and when item is Response=Approved the list item is created in another below list. I want the attachments to move too, do you know how to move the attachment?

    SharePointer · September 16, 2018 at 20:50

    I don’t think there is an action to ‘move’ the item but you can copy the item/file.

Christopher J Crocker · September 23, 2018 at 06:10

I am having some difficulty creating the path for the compose task.

I have a Document library, and in that I have a folder called “RFP – Repository” and within that a subfolder “Active”

I would like attachments copied to the path: …/RFP – Repository/Active/

When I use /share documents/RFP – Repository/Active/ the flow fails. No readme created and no attachments copied.

Do I need to do something special to identify my folder path correctly? I cannot seem to get this right.

Christopher J Crocker · September 24, 2018 at 20:39

Hi, I have this partially working.

A problem I seem to have is when I add 5 mixed attachment types, an excel file, pdf, word etc, I end up with only the first file added to the list item when the form was submitted.

If I attach 5 files that are all excel files, I get a 5 files copied into the document library folder.
If I attache 5 pdfs…. I only get 2 of the files.

What could be causing this?

Cindy · October 16, 2018 at 13:33

I’m sorry but I don’t understand what SharePoint Action I’m to choose when it comes to creating the text file since there is no Create Folder By Creating a Text file. Could you please provide me some guidance on that?

Thank you.

Cindy · October 16, 2018 at 14:12

Thanks so much for your help on this! I did find out where/how to create the “Create Folder by Creating a text file” but , like GR, it only created the Read me file and did not actually copy my attachments. Any idea what could be occurring?

When the flow failed it returned —
Get attachment content 3s – green check;
Compose 2 -0s – green check;
Create file 3 – 2s – green check;
Create file 4 – 0s, Red Explanation point.

I had three files attached to my original list item. Also, I “think” the “create file 3” is the readme text because that was, in fact, successful.

Thanks so much for your help!

SALVADOR LARA ROCHA · November 8, 2018 at 17:28

This also can be done on items already created? How can I go through the list?

    SharePointer · April 9, 2019 at 21:31

    You can create a manual or schedule action but remember if the size of the list if long you might run in the issues.

Jose Zaldivar · November 8, 2018 at 23:05

I had to make a few adjustments to this original code to work form me. I posted this screenshot below to show how I did it.
Basically, you create the folder first. Then you loop thru the attachments and place them in the folder. It works like a charm. If anyone wants to know the details, please reach out.

Olivier · November 21, 2018 at 19:50

Feel really stupid : when I want to use the “Get attachments” box, I can’t propose “ID” for the option is not in the list.

Karin · December 12, 2018 at 19:45

I tried this too and it creates the files just fine but when I try to open them, they are corrupted and cannot be viewed. I have tried several approaches to get around this but nothing works.

    SharePointer · August 22, 2019 at 15:23

    You must be using the wrong content. Anyway, now I have updated the blog with ‘Get file content’ which makes it simpler.

chris · January 11, 2019 at 01:44

I believe I have followed the instructions to a T but I can’t find Attachment Content in my dynamic content list anywhere. I have tried everything I can think of

sachin · June 15, 2019 at 10:37

Hi I follow all step to create the workflow but in my workflow, there is error occur can anybody help me because I am new in Microsoft flow

sachin sharma · June 15, 2019 at 10:41

An error occurs in my Flow Please help me

Andy Brim · August 22, 2019 at 19:12

This flow works great. Part of what I’m doing is replicating what a former co-worker setup on another site. There it does the same thing (create folders and move the attachments), but he also made it so there was a link to folder in one of the list columns. I have no idea how he did it since there is no Workflow, Flow, or otherwise. Any ideas?

    SharePointer · August 22, 2019 at 21:57

    Yes,all you need to do is to add a column in the document library and add the link value to that column. It would be good to create a modern documentset which works better with files inheriting metadata from folder.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.