I have been working a lot with PowerAPP and Flow 💡 with Muhimbi Actions in my recent weeks. This is my second Blog for Muhimbi.
In this Blog Post we will build a FLOW which will Loop though all the documents once a day in a OneDrive for Business Folder, Merge them and Create the Merged file in a different Folder.
Before we start building the FLOW, Let’s have a look at Final FLOW.
Does the above FLOW screen-shot look complicated? Don’t worry. For the sake of simplicity. I have broken the FLOW into two parts and will explain each and every step in details.
So without wasting time let’s get into the Meat and Potatoes.😀
Part 1:
Step 1: “Recurrence” The FLOW will run once a day.
Step 2: “Initialize variable” Flow action to store the Merged Contents of
Type: “String”
Initial value: Null
Step 3: “Initialize variable” Flow action to store the Merged Count
Type: “Integer”
Initial Value: Null
Step 4: Add the OneDrive for Business “List Files in folder” Action on the Folder library for which contain all the files that we need to be Merged.
Part 2:
Step 5:Add the “Apply to Each Loop” after Step 4 and add the Output(value) of “List Files in folder” (Step 4)
Step 6: This step will skip any sub-folder and will only select the files.
- Add a condition.
- IsFolder is the Output of “List Files in folder” (Step 4) and you need to set it to “False”.
Step 7: Now if the Step 6(above step) evaluates to True.
- Add the action “Get file Content using Path”
- File Path : Path is the Output of “List Files in folder” (Step 4)
Step 8:
- Add a condition.
- Merge Count is the Output of “Initialize variable – Merge Count” (Step 3).
Step 9:Now if the Step 8(above step) evaluates to True.
Add Muhimbi “Convert Document Action”
The Action has two parameters
- Source File Name: Name is the Output of “List Files in folder” (Step 4)
- Source File Content: File Content is the Output of “Get file Content using Path” (Step 7).
Step 10: Add the OneDrive for Business “Create File” action, under Step 9
The Action has three main parameters
- Folder Path: The Path of your destination Folder.
- File name: You can create a variable for File name but for Simplicity I have hardcode it “MergedFile.PDF”.
- File Content: “Processed File Content” Output of “Convert Document” Action(Step 9).
Step 11: Now if the Step 8(above step) evaluates to False i.e. Merge Count is now not equal to 0.
- Add the action “Get file Content using Path”
- File Path : For simplicity Hardcode the Path with reference to Step 10. i.e.“/MergedSource/MergeDestination/MergedFile.pdf”
Step 12: Now this is where the real Magic happens.
- Add the Muhimbi “Merge documents” Action.
- The Action has the following two main Parameters “Source File name” and “Source File Content”
Now let’s, configure this action.
- “Source File name -1”: Hardcode the File Name “MergedFile.pdf” This file name should be same as Step 10 and 11″.
- “Source File Content -1”: File Content is the output of “Get file Content using Path 2” Step 11.
- “Source File name -2”: Name is the Output of “List Files in folder” (Step 4).
- “Source File Content -2”: File Content is the output of “Get file Content using Path ” Step 8.
Step 13:Add the OneDrive for Business “Create File” action, under Step 12
The Action has three main parameters
- Folder Path: The Path of your destination Folder.
- File name: You can create a variable for File name but for Simplicity I have hardcode it “MergedFile.PDF”.
- File Content: “Processed File Content” Output of “Merge Document” Action(Step 12).
Step 14: Add the Set Variable Action outside the Condition.
The Action has two main parameters.
- Name: Select the “Merged Count” variable Initialized on Step 2
- Value: Set the Value 1
Now, for Testing Purposes you can set the “Recurrence” Frequency to “Minute”. This will trigger the Flow after a Minute and Merge the document.
But Remember ❗to set the Frequency to “Day”, you don’t want to exhaust all you Muhimbi Conversion.
The Size of the Merged PDF file too large? Do not worry… Just follow the blog Optimizing/Reducing the size of PDF files..
Happy Converting….
good blog for file merge
LikeLiked by 1 person
Step 12 needs to be updated, you have “Source File name -1 & Source File Content -2″ twice. IT should read “Source File name -1 & Source File Content -1″ first and then “Source File name -2 & Source File Content -2”
LikeLike
I am Glad that you followed the blog to the letter. I have updated the blog post!
If the files that you are trying to Merge are in SharePoint. You could reduce the number of merge operations using Muhimbi REST API directly from Microsoft Flow, for more details see my new blog post. https://powerusers.microsoft.com/t5/Microsoft-Flow-Community-Blog/Merge-SharePoint-documents-using-Microsoft-Flow-or-Azure-Logic/ba-p/247814
LikeLike
Hey! Do you use Twitter? I’d like to follow you if that would be okay. I’m undoubtedly enjoying your blog and look forward to new posts.
LikeLike