Power Automate Copy Folder + Power Automate Copy Folder Structure

In this Power Automate article, I will discuss a commonly used case in the SharePoint document library using Power Automate: the Power Automate copy folder action and how it is used in Microsoft Flow.

Also, I will demonstrate the following points:

  • Power Automate copy folder with a new name
  • Power Automate copy files from one Library to another
  • Power Automate copy folder structure
  • SharePoint copy folder structure without files using Power Automate
  • Power Automate rename file SharePoint

Power Automate Copy Folder with New Name

To copy the folder with a new name using Power Automate, see the example below:

For example, I have random files and folders in one SharePoint Document library [Sales Documents], i.e., the Source document library.

How to copy a folder with new name in Power Automate

I wanted to copy a folder from the source document library folder present in the SharePoint site [Finance Department] to the targeted library [Sales Documents] in another SharePoint site [Sales].

Power Automate copy a folder with a new name

Let’s create the Power Automate flow:

1. On the Power Automate Home page, go to + Create > Instant cloud flow > Select the trigger ‘Manually trigger a flow‘.

2. Then, add the Get folder metadata action. This action will get the information about the folder by using a file identifier to pick the folder.

  • Site Address– Set the source site address.
  • File Identifier– Set the folder path from where you will get the folder metadata.
Copy SharePoint folder with new name Power Automate

3. Next, I will add an action to copy the folder from the source site address to the destination site. Select the Copy folder flow action. Then, set the below properties, such as:

  • Current Site Address– Set the source SharePoint site address.
  • Folder to Copy– Select Body/Id from the dynamic content of the Get folder metadata.
  • Destination Site Address– Set the destination site address.
  • Destination Folder– Set the destination document library where you want to store the copied files and folders.
  • If another folder is already there– Set it as a Copy with a new name.

Note:

Copy with a new name option only allowas to take integer values from the dynamic content. If the folder/file is exist in library, it will just add an integer value to the existing name.
Power Automate copy folder and contents

4. Let’s save the flow and test it manually. Then click on Run the Flow.

5. When the flow triggers and runs successfully, you can see the folder has been copied with a new name if it already exists in the destination document library.

Copy a SharePoint folder with new name in Power Automate

This is how to copy a SharePoint document library folder using Power Automate.

Power Automate Copy files from one Folder to Another

Now, let’s check how to use Power Automate to copy files from one folder to another folder and from the SharePoint document library to another.

Example:

I have a SharePoint document library named ‘Training Related Documents‘ as shown in the following figure:

Power Automate copy files from one library to another

I also have one more document library like ‘Power Platform Course‘ looks like in the below image:

copy files from one library to another in Power Automate

Whenever a file is modified or created in the Training Related Documents -> Copy the file to another SharePoint document library [Power Platform Course].

Check out the steps below:

1. In Power Automate, select Automated cloud flow with the trigger ‘When a file is created or modified‘ -> Choose Site Address and Library name.

Power Automate copy file

2. After that, take the Copy file flow action. Configure the below given parameters:

  • Current Site Address: Select the SharePoint site from where you want to copy files.
  • File to Copy: Choose File Identifier from dynamic content of when a file is created or modified.
  • Destination Site Address: Choose a targeted SharePoint site.
  • Destination Folder: Select the document library from the open folder icon.
  • If another file is already there: Choose copy with a new name option from the drop down.
How to copy a file in Power Automate

3. Then, save and run the flow. Go back to the SharePoint document library and add or modify a file.

Power Automate copy file with new name

4. The flow will trigger and copy the created file to a targeted document library in SharePoint.

Refer to the image below:

Power Automate rename file SharePoint

This way, you can copy files from one document library to another using Power Automate.

Power Automate Copy Folder Structure without Files

To copy the SharePoint document library folder structure from one SharePoint site to another SharePoint site, follow the below example:

Example:

The below-represented image will show the SharePoint document library [Source Document Library] with a folder structure:

  • Invoices [Folder] -> Invoice 2024 [Folder] -> Invoice details.xlsx file
Power Automate copy folder structure

I have another SharePoint site [Sales] with another empty document library [Sales Documents], as shown in the figure:

Copy folder Power Automate

My requirement is to copy the folder structure without files from a source document library [Sales Documents] to the Targeted SharePoint document library [Sales Documents].

Check out the instructions below:

1. Navigate to the Power Automate Home page, select Instant Cloud flow, choose Manually trigger a flow action, and Click the Create button.

2. Now, add the Get files(Properties only) flow action -> Select the Site Address and Library Name from where you want to copy the folder structure.

SharePoint copy folder structure Power Automate

3. After that, take an Initialize variable flow action, name the variable, and select the datatype as String.

Power Automate SharePoint copy folder structure

4. After that, create one more initialized variable for the folder path, providing a name for the variable and a String datatype.

How to copy folder structure in SharePoint Power Automate

5. Next, add a Condition control action to filter out only document folders, excluding files from the SharePoint library.

Choose ValueOperatorChoose Value
IsFolder [Dynamic content]is equal totrue()
SharePoint copy folder structure with files in Power Automate

6. Under the True condition, select Set variable action. Configure the parameters:

  • Name: Choose the name from the drop-down as Full Path that we have taken the variable action.
  • Value: Select FullPath from the dynamic content.
Power Automate copy folder structure from SharePoint

7. Again, take another Set Variable action under the True condition. Choose the parameters:

  • Name: Select the name as Folder Path from the drop-down.
  • Value: Insert the expression below that will only take the folder path from the full path.’
substring(variables('Full Path'),15,sub(length(variables('Full Path')),15))

In the above-given expression, replace the number with the length of your document library name.

Microsoft Power Automate copy folder structure

8. Finally, take the Create new folder flow action. Ensure to give the below parameters:

  • Site Address: Choose the targeted SharePoint site.
  • List or Library: Select the destination SharePoint document library where you want to copy the folders.
  • Folder Path: Select the variables of the folder path from the dynamic content.
How to copy SharePoint folder structure in Power Automate

9. Now the flow is ready, save the flow. Click on Test -> Select Manually radio button -> Click Runflow.

10. Once the flow runs successfully, you can see that the folder structure has been copied from the source library to the destination library in SharePoint.

Copy folder structure without files in SharePoint Power Automate

This way, you can copy folder structure from one SharePoint document library to another using Power Automate.

Power Automate Rename File SharePoint

To rename the SharePoint document library files using Power Automate, follow the below points:

Renaming a file flow action is not available directly in Power Automate. If we want to rename the file name, we would need to create a copy of the file and remove the previous one.

I have a SharePoint document library with a few files and folders, as looked at in the image below:

I wanted to rename the highlighted files from the below picture:

Power Automate Rename File SharePoint Document Library

Check out the below steps:

1. Browse to https://make.powerautomate.com/, click on +Create, select Instant cloud flow, choose Manually trigger a flow, and tap on the Create button.

Inside the trigger, take a text input to provide the File name.

2. Add a Get file metadata flow action. Add details like Site Address and library Name.

Power Automate copy files and contents

3. In the next step, add the Get file content action and configure the required parameters:

  • Site Address: Choose the SharePoint site or enter the custom value.
  • File Identifier: Select body/Id value from the dynamic content.
Power Automate rename a file with new name

4. Select the Create file action in SharePoint and fill in details like the Site Address and Folder path.

  • File Name: Provide the file name along with the date expression.
@{triggerBody()?['text']}-@{formatDateTime(utcNow(),'dd-MM-yyyy')}.docx
  • File Content: Take the File content Body under Get file content.
Rename a file with new name Power Automate

5. After creating the file, delete the old existing file. Select Delete File action.

  • Site Address: Enter the site address from custom value.
  • File Identifier: Select Body/Id from Get file metadata of dynamic content.
@{outputs('Get_file_metadata')?['body/Id']}
Rename a SharePointfile with new name Power Automate

Once it is done, save and run the flow manually. In the Runflow window, provide a file name and click on the Runflow button.

Power Automate copy SharePoint document file

6. The below-represented image shows that the file has been renamed in the SharePoint document library.

How to rename a SharePoint file Power Automate

This is how to rename a file in the SharePoint document library using Power Automate.

Some more Power Automate articles you may also like:

Conclusion

I hope this article will be helpful. In this article, we have discussed about Power Automate copy folder, how to copy folder in Power Automate with a new name, Power Automate Copy Folder Structure, and a lot more.

  • Thank you Bijay, very useful! I work with libraries that often may have more than 50,000 files, in folder structures. Files may have been tagged with retention labels. Are there any showstoppers you may warn about when dealing with large libraries and the workflows you presented?

    Cheers!

  • >