Optimize loop Flow

Copper Contributor

Hi all,


I have a Power Automoate flow that I use to move files from one folder to another.
I check whether the folder number in a "Number" column corresponds to the column in another folder to ensure that the moved file ends up in the right folder.
I therefore have a condition in my Power Automate flow that loops over all the folders until it finds a match before moving my file.Capture.PNG
The problem is the execution time. It takes about 2 minutes for the flow to run. How can I optimise this?

5 Replies

Hi @LouisT645 , have you considered using an expression to generate the destination folder path and moving based on that, avoiding the condition? I appreciate you may be wanting to ensure a destination folder exists.

Hi, thank you for the answer. What do you mean with the condition?
The fact is that I really need to know if the folder is already created, if not I send an error message to the team to avoid the files everywhere

Hi @LouisT645 , my initial interpretation of your question was that the source folder name is numbered. Using that number you could avoid questioning whether the destination folder exists, but I'm now doubting my understanding. Can you expand the detail of the source files/folders and the destination folders?

@Jon_Lake yeah sure.


I developped multiple Power Automate flows to manage invoices, I have a Document Library with all my invoices and some columns like "name", "Building Number", Property Manager",...

One of my flow is to move the invoice from the folder named "all Invoices" to the folder with all the buildings we manage.

I use the column "Building Number" to find the correct folder to store the invoice in the "accounting" folder ine the correct building.

So I loop on all the buildings numbers and if 2 numbers are the same, the flow store the invoice in the correct  building folder

Hi @LouisT645 , happy new year!


I may have figured out a solution.

My folder structure is setup like this.


All files awaiting re-location would go into the 'source_docs' folder, which looks like this with docs in.


The flow gets all file properties for those files in the source docs folder, then for each it moves it to the folder matching the building name attribute.


This works well, though when you first add the move file action it will create within a child loop, so you do need to drag the move file action out of that child loop, down as a new action within the parent loop. My limited testing has proven successful so far. Hopefully it will help.