“I need to archive files from multiple SharePoint libraries, can I copy them in a single Power Automate flow or do I need one flow per library?”
File copying flow is one of the common use cases for Power Automate. It’s a simple flow to copy files from one library to another, as described in a previous post. But that flow will copy files only from one library to another. If you want to copy files from another library, you’d need another flow. And another one for the next library. And this could go on for each document library, leading to many copies of the same flow. Unless there’s another way – one flow with a configuration that’ll do all the work.
Create configuration list in SharePoint
Since the process is always the same, you don’t need separate flows. You can have a single flow and only change the libraries. It’ll process the 1st library, then the 2nd library, 3rd library, and so on. But you’ll need 4 pieces of information for each location stored somewhere: the source site and library, and the target site and library. From where should the flow take the documents, and where should it copy them.
The easiest way to store this information is to create a SharePoint list with the configuration. Create a new list with 4 columns: SourceSite (you can rename the Title column), SourceLibrary, TargetSite and TargetLibrary. The name is not that important, but all the columns should be ‘Single line of text’ columns.
This list will serve as the configuration for the flow.
Add information in that list
Add configuration for each library you want to process in the flow. For the SourceSite just copy the url to the site. The SourceLibrary is the display name of the library. The TargetSite is the url to the site where you want to copy the documents. And the TargetLibrary is the path to the library/folder where the files should be stored.
Notice the difference between the SourceLibrary and TargetLibrary. It’s because each of them is used in a different action. SourceLibrary is used in the ‘Get files (properties only)’ where it asks for the library name. But the TargetLibrary is used in the ‘Copy file’ action where it needs the library url.
Use the configuration list in the flow
Once you have the configuration list, you can load it into the flow with the ‘Get items’ action.
Each returned item will represent one line from your configuration. Loop through all the items and ‘Get file (properties only)’ for each source site and source library.
For each returned file copy the file to the target site and target library. Everything except the file identifier will be available among the dynamic content, but the file identifier must be entered as an expression.
The reason is that you’re using dynamic configuration in the ‘Get files (properties only)’ action, therefore, it doesn’t know the library structure. But the identifier is an internal column, it’s always the same.
The result is a single flow that’ll go through the configuration and process the libraries one by one. No matter how many libraries you define, it’ll be still a single flow.
If you use Power Automate to copy files between SharePoint libraries, you don’t need one flow per library. You can use a configuration list instead. Define all the required information for each library in a SharePoint list, load the data in your flow, and repeat the actions for each library. And if there’s a new library, just add it to the configuration list.
The use of the configuration list was shown on a simple flow copy files, but you can use the same concepts on the extended versions too. You can use the same approach also to copy files including the folder structure or to update existing files. And when talking about configuration lists, it’s not limited to file related flows, you can use them in approval flows as well.