Upload multiple files in SharePoint using Power Automate – more than 5000 documents

Upload multiple files in SharePoint using Power Automate – more than 5000 documents

No comments

 7 total views,  7 views today

In this “Upload multiple files in SharePoint using Power Automate” article, we will learn how quickly we can upload multiple files (more than 5000) in the SharePoint Online document library.

If we want to test the SharePoint document library threshold limit issue, we need to have a document library with more than 5000 documents. So, in this Power Automate flow, we will learn how to create multiple files very quickly.

Upload multiple files in SharePoint using Power Automate

Before getting into the Power Automate, let’s talk about the prerequisites.

Prerequisites: Upload multiple files in SharePoint

As part of the prerequisites, perform the below:

  • Create a document library called “UploadMoreThan5KDocuments.”
  • Create a folder named “Template.”
  • Manually upload the sample file named “TemplateFile.docx.”
  • Optional: Create a choice type column named “ItemCreatedChannel” with the value “Manual” or “Power Automate”

 

Upload multiple files in SharePoint Online document library using Power Automate
Upload multiple files in SharePoint Online document library using Power Automate

Power Automate: Create multiple files in SharePoint

Below is the Power Automate flow that will create multiple files in the SharePoint Online document library.

Power Automate flow to create multiple files in SharePoint
Power Automate flow to create multiple files in SharePoint

This is a manually triggered flow. It has two sections:

  • Variable declaration
  • Do Until Loop

Variable declaration section: Create multiple files in SharePoint

Initialize below two variables:

  • intVarItemCount – Integer Type with initial value 1. This number is the starting number of the loop.
  • strVarItemTitleToBeCreated – String Type, This will be passed in the Name column as value.
Initialize variable in auto increment number in power automate
Initialize variable in auto increment number in power automate

Get file content using path in Power Automate

Add a “Get file content using path” action and pass the below parameters:

  • Site Address: Your site URL
  • File Path: Select your template file uploaded in the prerequisites section. This is the key template file; based on this file, other files will be created.
Get File Content using Path in Power Automate
Get File Content using Path in Power Automate

Do Until Loop Power Automate: Auto increment number in power automate to add multiple files in SharePoint

Below is the Do Until loop section.

Do Until Loop Power Automate - Auto increment number in power automate to add multiple files in SharePoint

Auto increment number in power automate to add multiple files in SharePoint
Auto increment number in power automate to add multiple files in SharePoint

Explanation of Do Until Loop Power Automate

Step 1:

Step 1:


@variables('intVarItemCount') is equal to 5000

In change limit, count is equal to 5000

Changes limit in Do Until Power Automate loop
Changes limit in Do Until Power Automate loop

Notes:

  • The default change limit is 60, you must change to the desired number you want to create in the list.
  • For example, we have given the number 5000, however, you could give any positive number which is less than or equal to 5000. More than 5000 numbers, will not accept.
  • This number count control how many items should be created in the list.
  • If you want to create more than 5000 items in the list, then you need to execute this flow more than once or you need to execute this in batch.

Step 2:

Add a compose action and add the “intVarItemCount” variable in it.


@{variables('intVarItemCount')}

Add compose action Power Automate Do Until Loop

Step 3:

Add compose action to convert the number to a string. Add the below value to the compose action.


string(outputs('Compose_-_Item_Sequence_Number'))

Add compose action to convert number to string

Add compose action to convert number to string

Step 4:

Add a set variable action for the “strVarItemTitleToBeCreated” variable. And using the Concat function add two strings (‘Item_’ and ‘incremented number).


concat('Document_',outputs('Compose_-_Convert_item_sequence_to_string'),'.docx')

Concat function add two string in Power Automate

The Concat function add two string in Power Automate

Note:

  • Here we created the file name as “Document_1”, “Document_2”, and “Document_3”, etc. However, you could give some other values. Here the “Document_” part is fixed and the number part is dynamic (auto-incremented).

Step 5: Create file action in Power Automate

Add a “Create file” action and pass the below parameters:

  • Site Address: Your site URL
  • Folder Path: Select the document library path where you want to upload the files; here we have selected the document library root folder.
  • File Name: Pass the file name from the previous step, “strVarItemTitleToBeCreated”
  • File Content: Pass the body of the get file content using path or directly use this – @{body(‘Get_file_content_using_path’)}

Create file action in Power Automate

Create file action in Power Automate

Step 6: Update file properties in Power Automate (Optional step)

Add an update file properties action and pass the below parameters:

  • Site Address: Your site URL
  • Library Name: Your document library name
  • Id: Item ID from the previous step create file action or directly like use this – @{outputs(‘Create_file’)?[‘body/ItemId’]}
  • Title (Optional): Here we have passed the title as “Document_ItemID”, for this we have passed as –
    concat(‘Document_’,outputs(‘Create_file’)?[‘body/ItemId’])
  • ItemCreatedChannel Value (Optional) – Select as Power Automate (it has two values, Power Automate and Manual)
Update file properties in Power Automate
Update file properties in Power Automate

Step 7: Final Step

Increment the “intVarItemCount” variable by 1. For that add increment variable action.

Add increment variable to auto increment number in Power Automate
Add increment variable to auto increment number in Power Automate

That’s it we are done with the flow. Now let’s run the flow manually as this type of manually triggered flow. Then, take a break, then see the status, you could see that 5000 documents have been created in the document library.

Create more than 5000 documents in SharePoint using Power Automate – Demo

We could see that 5000 documents have been created in the list ‘AddMoreThan5KDocuments’ library.

Create more than 5000 documents in SharePoint using Power Automate
Create more than 5000 documents in SharePoint using Power Automate

Summary: Add multiple Documents in SharePoint using power automate (upload files to SharePoint using Power Automate )

Thus, in this article, we have learned how to add multiple documents in the SharePoint Online document library using Power Automate by auto-incrementing numbers inside the do until loop. And also we have learned the below:

  • How to use get file content using path action in Power Automate.
  • How to use create file action in Power Automate.
  • How to use get file properties in Power Automate.

See Also: Power Automate Tutorial

You may also like the below Power Automate tutorials:

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment