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:
The Destination Library Folder is empty.
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.
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.
Step-3:
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.
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.
And we can see our Source Library Folder is empty because we have moved all the files to the Destination Library Folder.
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:
- 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.
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.
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.
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:
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.
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.
We can see that none of the files and nested items are moved to the destination library folder in the Souce library folder.
This is how to Move files from one folder to another in SharePoint using Power Automate flow.
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.
In the OneDrive My files -> DestinationFolder, we can see the folder is empty.
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.
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.
- 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.
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.
Step-4:
Save and run the flow by selecting the run flow option. Once flow ran successfully like below:
It moves all the files to the Destination folder from the Source folder in OneDrive using Flow.
And we can see our Source Folder is empty because we have moved all the files to the Destination Folder and deleted them.
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:
- Convert HTML to Text using Power Automate
- Create XML file from CSV in Power Automate
- Create a Folder in SharePoint using Power Automate
- Create a sharing link for a file or folder using Power Automate
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.