Forum Discussion
Optimize loop Flow
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.
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
- Jon_LakeDec 29, 2023Brass Contributor
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?
- LouisT645Dec 29, 2023Copper Contributor
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
- Jon_LakeJan 02, 2024Brass Contributor
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.