Power Automate: Unzip and Extract files with .zip Extension

Introduction

In this article, we will see how to unzip files with the .zip extension using Power Automate. We will use a qualified business use case as the base for the article.

Business Use Case

We maintain a SharePoint Document Library that accepts multiple invoices which are sent as a zip file by vendors. However, for further processing, individual invoices need to unzip from the .zip file. We will use Power Automate to achieve the unzipping of the Invoices Zip file in this scenario.

Implementation

Let’s create an automated cloud flow that runs whenever a new file is created in the Document Library.

Graphical user interface, text, application, email

Description automatically generated

However, we need to restrict the trigger to ensure that the flow will run only when a zip file is uploaded. To ensure this, we can use the trigger condition and add a new condition by clicking on Add button at the bottom.

Graphical user interface, text, application, email

Description automatically generated

So as to formulate the condition, an easy way to do it temporarily adds a compose action and click on the Expression tab and add the expression contains(,’.zip’) and within the parenthesis as the first parameter add the dynamic content” Filename with extension”. The final expression will look like below.

contains(triggerOutputs()?[‘body/{FilenameWithExtension}’],’.zip’)
Graphical user interface, application

Description automatically generated

Copy the expression and paste it in the trigger condition with an @ in the beginning. This will ensure that the flow gets triggered only when this condition is met.

Note: This is a neat way to apply conditions that use the Condition action and checking inside the flow as it helps in reducing the flow run if the condition is not met.

Graphical user interface, text, application, email

Description automatically generated

Now let’s add a new action “Create a new folder” to use to house the extracted files from the zip. In the folder name, mention the name that needs to be used for creating the folder, we will use the name of the Zip file as the value for this parameter.

Once the folder action is configured, let’s add the Extract Folder action to extract the zip and save the extracted files in the previously created folder. We have 2 parameters that will be updated with the below values:

Source File Path

The full path of the zip file from the item created action

Destination File Path

The full path of the newly created folder

Graphical user interface, text, application, email

Description automatically generated

Thus, the flow configuration is completed and the completed flow would look like:

Graphical user interface, text, application

Description automatically generated

Test the flow

To test the flow, we will upload a zip file that has 3 invoice files to the document library. This would kick start the flow and firstly it would create a new folder for storing the unzipped files

Graphical user interface, text, application

Description automatically generated

Followed by that, if we go inside the newly created folder, we can see that the file has been unzipped and copied to the new location.

Graphical user interface, text, application, email

Description automatically generated

Summary

Thus, we saw how to use Power Automate to unzip a file and create a new folder by the same name and store the unzipped files in the new folder so that these files can be directly read by other automation processes for future operations.

Related Articles

Author

Author

Priyaranjan KS is a Modern Workplace Architect primarily focused on developing and architecting solutions around Office 365,Power Platform and Azure.He is also a Microsoft Most Valuable Professional(MVP) and a Microsoft Certified Trainer(MCT)

Latest Articles