How to Move files from one folder to another using Power Automate?

In this Power Automate tutorial, we will learn how to move files from one folder to another using Power Automate.

I will show you 2 examples here; in one example, we will see how to move files from one folder to another in SharePoint Online, and in the other example, we will see how to move files from one folder to another in OneDrive using Power Automate flow.

Move files from one folder to another using Power Automate

Let us see how to move files from one folder to another using the Power Automate flow

Example-1: (Move files from one folder to another in SharePoint)

In this example, we will use two folders called SourceLibrary and DestinationLibrary in SharePoint Online Document Library.

In the Source Library Folder, we have two Excel workbooks and also a sub-folder with a single workbook presented as shown below:

Power Automate move files from one folder to another

The Destination Library Folder is empty.

Move files from one folder to another using the Power Automate

We want to move all the files from the Source Library folder to the Destination Library folder in SharePoint using Power Automate flow.

Here we will create a button flow, and when a user clicks on it, the files will be moved from one library or folder to another.

To achieve this, follow the below steps:

Step-1:

Create an instant cloud flow, Then select ‘Manually trigger a flow‘ to trigger the flow manually. Click Create to start the flow.

How to Move files from one folder to another using Power Automate

Step-2:

  • Select +New step -> Get files(properties only) action to get file properties from the SharePoint document library.
  • Configure the SharePoint site address and the Library Name.
    • Site Address- Specify the SharePoint site address.
    • Library Name– Select the Document library name from the dropdown.
  • In the Limit Entries to Folder select the SourceLibray from the Show Picker only then it takes files from the specific folder. If we leave Limit Entries to Folder blank, it takes all the files presented in the SharePoint Document library.
  • In the Include Nested items, select the yes option from the dropdown, so that it also moves the nested folders and files to the destination library folder from the source library.
Power Automate move files from one folder to another example

Step-3:

See also  How to Convert Float to Integer in Power Automate?

Case-1: (If another file is already there – Replace)

  • Select +New step and Move file action from the action triggers. Provide the below-required details:
    • Current Site Address – Select the source SharePoint site address from the dropdown.
    • File to Move – Select Identifier from the dynamic content of the Get files(Properties only). It will automatically apply to each control to move each file from the source folder to the destination folder.
    • Destination Site Address – Choose the destination site address from the dropdown.
    • Destination Folder – Select the DestinationLibrary from the Show Picker only then does it move all files from the SourceLibrary to the Destination Library.
    • If another file is already there – There are three options available,
      • Fail this action – Stops the Move File action
      • Move with a new name – If the files already exist, it moves the file with a new name to the selected destination folder.
      • Replace – If the files already exist, it moves and replaces them in the selected Destination Folder. In this example, I have selected the Replace Option.
Example to Move files from one folder to another using Power Automate flow

Save and run the flow by selecting the run flow option. Once flow ran successfully like below:

It moves all the files and nested items to the Destination Library folder from the Source Library folder.

move files from one folder to another example in Power Automate flow

And we can see our Source Library Folder is empty because we have moved all the files to the Destination Library Folder.

how to Move files from one folder to another in SharePoint using Power Automate

Case-2: (If another file is already there – Move with a new name)

The Source Library Folder consists of the below files and nested items:

Power Automate move files from one folder to another
  • Similarly, in Step-3: In the move file action If another file is already there section when we select Move with a new name option. It moves all the files and nested items to the destination library with the auto-generated new file name.
  • For example, If the file or folder name is Test it creates a new file or folder name as Test1.
Power Automate move files from one folder to another folder example

Once our flow runs successfully, we can see all the files and nested items are moved to the Destination Library folder from the Source Library folder with a new name.

Example on how to move files from one folder to another folder in Power Automate flow

Now our Source Library Folder is empty. Because all the files and nested items are moved to the Destination Library Folder with a new name.

how to Move files from one folder to another in SharePoint using Power Automate

Case-3: (If another file is already there – Fail this action)

The below screenshot displays the files and nested items presented in the Source Library Folder:

Example to move files from one folder to another folder in Power Automate flow

In the same way, in Step-3: In the move file action If another file is already there section when we select Fail this action option. It will not move any files from the source library to the destination library.

move files from one folder to another example in Power Automate

In the Destination library, we can see either it doesn’t move files and nested items with a new name, or it replaces any of the files and nested items. Instead, it fails the Move file action.

Example on how to move files from one folder to another folder in Power Automate

We can see that none of the files and nested items are moved to the destination library folder in the Souce library folder.

Example to move files from one folder to another folder in Power Automate flow

This is how to Move files from one folder to another in SharePoint using Power Automate flow.

See also  How to Update DataCard Value in Power Apps

Example-2: (Move files from one folder to another in OneDrive)

Here, we will see how to move files from one folder to another in OneDrive using Power Automate flow.

In this example, we will use SourceFolder and DestinationFolder in OneDrive.

Three Excel workbooks are presented in the OneDrive My files -> Source Folder.

Move files from one folder to another in OneDrive using the Power Automate

In the OneDrive My files -> DestinationFolder, we can see the folder is empty.

Move files from one folder to another in OneDrive using the Power Automate flow

Using Power Automate flow, we will learn how to move all the files from the Source folder to the Destination folder in OneDrive. Follow the below-mentioned steps:

Step-1:

  • Create an instant cloud flow with the Manual trigger flow action. Then add +newstep and select the List file in Folders action from OneDrive for business action triggers.
  • In the Folder, select the Source Folder path by using Show Picker.
How to Move files from one folder to another in OneDrive using Power Automate

Step-2:

  • Then, we will add a Get the file content action to get the content of a file. Here we will Pass the File ID from the dynamic content of the previous action i.e. list files in the folder.
  • It will automatically create an apply to each control to loop through each file presented in the Source Folder.
How to Move files from one folder to another in OneDrive using flow
  • Now Add an action to create file. Here we will not use the Move or Rename a file action, just because it supports only a single file.
  • We have three Excel workbooks in the source folder, so we will use the create file action to move all three files to the Destination folder. Provide the below details:
    • Folder Path – Select the Destination Folder from the Show Picker
    • File Name – Pass the Dynamic content value Name for the file name
    • File Content – Add File content from the dynamic content value.
Example to Move files from one folder to another folder using Power Automate

Step-3:

  • Select +Add new step and add a Delete file action to delete all the files that are presented in the Source Folder.
  • Here we will Pass the File Id from the dynamic content of the list files in the folder action.
  • It will automatically create an apply to each control to loop through and delete each file presented in the Source Folder, which is already moved to the Destination Folder.
Example to Move files from one folder to another folder using the Power Automate

Step-4:

See also  How to Create a Folder in SharePoint using Power Automate?

Save and run the flow by selecting the run flow option. Once flow ran successfully like below:

Move files from one folder to another folder in OneDrive using Power Automate flow

It moves all the files to the Destination folder from the Source folder in OneDrive using Flow.

Move files from one folder to another folder in OneDrive using Power Automate

And we can see our Source Folder is empty because we have moved all the files to the Destination Folder and deleted them.

Move files from one folder to another in OneDrive using Power Automate flow example

This is how to move all the files from the Source folder to the Destination folder in OneDrive using Power Automate.

Conclusion

In this Power Automate tutorial, we have learned how to move files from one folder to another using Power Automate. I have explained how to move files from one folder to another in OneDrive.

You may also like:

>